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
.libs
.*.swp
*.*~*
*~
*.bak
*.rej
*.orig

View File

@ -11,7 +11,7 @@
# 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
# 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
# <http://randspringer.de/boost/index.html>.
#
@ -151,7 +151,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
else
search_libsubdirs="$multiarch_libsubdir $libsubdirs"
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
for libsubdir in $search_libsubdirs ; do
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
else
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
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/_/./'`

View File

@ -7,7 +7,7 @@ linux_release_CXXFLAGS=$(linux_release_CFLAGS)
linux_debug_CFLAGS=-O1
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)))
i686_linux_CC=gcc -m32

View File

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

View File

@ -501,6 +501,11 @@ enum Network CNetAddr::GetNetwork() const
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)
{
assert(a.size() == ADDR_IPV6_SIZE);
@ -521,6 +526,7 @@ std::string CNetAddr::ToStringIP(bool fUseGetnameinfo) const
{
switch (m_net) {
case NET_IPV4:
return IPv4ToString(m_addr);
case NET_IPV6: {
if (fUseGetnameinfo) {
CService serv(*this, 0);
@ -533,9 +539,6 @@ std::string CNetAddr::ToStringIP(bool fUseGetnameinfo) const
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);
}
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>
VectorReader& operator>>(T& obj)
VectorReader& operator>>(T&& obj)
{
// Unserialize from this stream
::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_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)
{
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 rv;
std::string rv(s.size() * 2, '\0');
static constexpr char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
rv.reserve(s.size() * 2);
for (uint8_t v: s) {
rv.push_back(hexmap[v >> 4]);
rv.push_back(hexmap[v & 15]);
auto it = rv.begin();
for (uint8_t v : s) {
*it++ = hexmap[v >> 4];
*it++ = hexmap[v & 15];
}
assert(it == rv.end());
return rv;
}

View File

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