Merge pull request #4262 from PastaPastaPasta/backport-triv-pr17

Backport triv pr17
This commit is contained in:
UdjinM6 2021-07-16 20:30:46 +03:00 committed by GitHub
commit 88da87d202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 24 deletions

2
.gitignore vendored
View File

@ -58,7 +58,7 @@ libconftest.dylib*
.dirstamp .dirstamp
.libs .libs
.*.swp .*.swp
*.*~* *~
*.bak *.bak
*.rej *.rej
*.orig *.orig

View File

@ -11,7 +11,7 @@
# Test for the Boost C++ libraries of a particular version (or newer) # Test for the Boost C++ libraries of a particular version (or newer)
# #
# If no path to the installed boost library is given the macro searchs # If no path to the installed boost library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the # under /usr, /usr/local, /opt, /opt/local and /opt/homebrew and evaluates the
# $BOOST_ROOT environment variable. Further documentation is available at # $BOOST_ROOT environment variable. Further documentation is available at
# <http://randspringer.de/boost/index.html>. # <http://randspringer.de/boost/index.html>.
# #
@ -151,7 +151,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
else else
search_libsubdirs="$multiarch_libsubdir $libsubdirs" search_libsubdirs="$multiarch_libsubdir $libsubdirs"
fi fi
for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local /opt/homebrew/; do
if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then
for libsubdir in $search_libsubdirs ; do for libsubdir in $search_libsubdirs ; do
if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
@ -227,7 +227,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
fi fi
else else
if test "x$cross_compiling" != "xyes" ; then if test "x$cross_compiling" != "xyes" ; then
for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local /opt/homebrew ; do
if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then
for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`

View File

@ -7,7 +7,7 @@ linux_release_CXXFLAGS=$(linux_release_CFLAGS)
linux_debug_CFLAGS=-O1 linux_debug_CFLAGS=-O1
linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) linux_debug_CXXFLAGS=$(linux_debug_CFLAGS)
linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_LIBCPP_DEBUG=1
ifeq (86,$(findstring 86,$(build_arch))) ifeq (86,$(findstring 86,$(build_arch)))
i686_linux_CC=gcc -m32 i686_linux_CC=gcc -m32

View File

@ -74,12 +74,11 @@ template <typename WorkItem>
class WorkQueue class WorkQueue
{ {
private: private:
/** Mutex protects entire object */
Mutex cs; Mutex cs;
std::condition_variable cond; std::condition_variable cond GUARDED_BY(cs);
std::deque<std::unique_ptr<WorkItem>> queue; std::deque<std::unique_ptr<WorkItem>> queue GUARDED_BY(cs);
bool running; bool running GUARDED_BY(cs);
size_t maxDepth; const size_t maxDepth;
public: public:
explicit WorkQueue(size_t _maxDepth) : running(true), explicit WorkQueue(size_t _maxDepth) : running(true),
@ -95,7 +94,7 @@ public:
bool Enqueue(WorkItem* item) bool Enqueue(WorkItem* item)
{ {
LOCK(cs); LOCK(cs);
if (queue.size() >= maxDepth) { if (!running || queue.size() >= maxDepth) {
return false; return false;
} }
queue.emplace_back(std::unique_ptr<WorkItem>(item)); queue.emplace_back(std::unique_ptr<WorkItem>(item));
@ -111,7 +110,7 @@ public:
WAIT_LOCK(cs, lock); WAIT_LOCK(cs, lock);
while (running && queue.empty()) while (running && queue.empty())
cond.wait(lock); cond.wait(lock);
if (!running) if (!running && queue.empty())
break; break;
i = std::move(queue.front()); i = std::move(queue.front());
queue.pop_front(); queue.pop_front();
@ -469,8 +468,6 @@ void StopHTTPServer()
thread.join(); thread.join();
} }
g_thread_http_workers.clear(); g_thread_http_workers.clear();
delete workQueue;
workQueue = nullptr;
} }
// Unlisten sockets, these are what make the event loop running, which means // Unlisten sockets, these are what make the event loop running, which means
// that after this and all connections are closed the event loop will quit. // that after this and all connections are closed the event loop will quit.
@ -490,6 +487,10 @@ void StopHTTPServer()
event_base_free(eventBase); event_base_free(eventBase);
eventBase = nullptr; eventBase = nullptr;
} }
if (workQueue) {
delete workQueue;
workQueue = nullptr;
}
LogPrint(BCLog::HTTP, "Stopped HTTP server\n"); LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
} }

View File

@ -501,6 +501,11 @@ enum Network CNetAddr::GetNetwork() const
return m_net; return m_net;
} }
static std::string IPv4ToString(Span<const uint8_t> a)
{
return strprintf("%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
}
static std::string IPv6ToString(Span<const uint8_t> a) static std::string IPv6ToString(Span<const uint8_t> a)
{ {
assert(a.size() == ADDR_IPV6_SIZE); assert(a.size() == ADDR_IPV6_SIZE);
@ -521,6 +526,7 @@ std::string CNetAddr::ToStringIP(bool fUseGetnameinfo) const
{ {
switch (m_net) { switch (m_net) {
case NET_IPV4: case NET_IPV4:
return IPv4ToString(m_addr);
case NET_IPV6: { case NET_IPV6: {
if (fUseGetnameinfo) { if (fUseGetnameinfo) {
CService serv(*this, 0); CService serv(*this, 0);
@ -533,9 +539,6 @@ std::string CNetAddr::ToStringIP(bool fUseGetnameinfo) const
return std::string(name); return std::string(name);
} }
} }
if (m_net == NET_IPV4) {
return strprintf("%u.%u.%u.%u", m_addr[0], m_addr[1], m_addr[2], m_addr[3]);
}
return IPv6ToString(m_addr); return IPv6ToString(m_addr);
} }
case NET_ONION: case NET_ONION:

9
src/qt/android/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
/.gradle
/build
/gradle/wrapper
/gradlew*
/libs
/res/layout
/res/values*
/src/org/kde
/src/org/qtproject

View File

@ -174,7 +174,7 @@ public:
} }
template<typename T> template<typename T>
VectorReader& operator>>(T& obj) VectorReader& operator>>(T&& obj)
{ {
// Unserialize from this stream // Unserialize from this stream
::Unserialize(*this, obj); ::Unserialize(*this, obj);

View File

@ -114,6 +114,17 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
BOOST_CHECK_THROW(reader >> d, std::ios_base::failure); BOOST_CHECK_THROW(reader >> d, std::ios_base::failure);
} }
BOOST_AUTO_TEST_CASE(streams_vector_reader_rvalue)
{
std::vector<uint8_t> data{0x82, 0xa7, 0x31};
VectorReader reader(SER_NETWORK, INIT_PROTO_VERSION, data, /* pos= */ 0);
uint32_t varint = 0;
// Deserialize into r-value
reader >> VARINT(varint);
BOOST_CHECK_EQUAL(varint, 54321);
BOOST_CHECK(reader.empty());
}
BOOST_AUTO_TEST_CASE(bitstream_reader_writer) BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
{ {
CDataStream data(SER_NETWORK, INIT_PROTO_VERSION); CDataStream data(SER_NETWORK, INIT_PROTO_VERSION);

View File

@ -606,14 +606,15 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa
std::string HexStr(const Span<const uint8_t> s) std::string HexStr(const Span<const uint8_t> s)
{ {
std::string rv; std::string rv(s.size() * 2, '\0');
static constexpr char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7', static constexpr char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
rv.reserve(s.size() * 2); auto it = rv.begin();
for (uint8_t v : s) { for (uint8_t v : s) {
rv.push_back(hexmap[v >> 4]); *it++ = hexmap[v >> 4];
rv.push_back(hexmap[v & 15]); *it++ = hexmap[v & 15];
} }
assert(it == rv.end());
return rv; return rv;
} }

View File

@ -151,7 +151,7 @@ def test_ipv6_local():
have_ipv6 = True have_ipv6 = True
try: try:
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
s.connect(('::1', 0)) s.connect(('::1', 1))
except socket.error: except socket.error:
have_ipv6 = False have_ipv6 = False
return have_ipv6 return have_ipv6