Package: src:opendht
Version: 3.0.1-1.1
User: [email protected]
Usertags: python3.15
Tags: patch, ftbfs, forky, sid
Hi!
While rebuilding the python related packages against the Python 3.15rc1
version we found that opendht fails to build from source [1].
The error is:
/build/reproducible-path/opendht-3.0.1/src/peer_discovery.cpp:219:17:
error: ‘using std::__shared_ptr_access<asio::io_context,
__gnu_cxx::_S_atomic, false, false>::element_type = class
asio::io_context’ {aka ‘class asio::io_context’} has no member named
‘post’
And this is caused by incompatibilities with newer asio versions.
This can be fixed with two upstream changes:
- upstream commit c2d8b19 http: fix service name resolution failure [2]
- upstream commit 33f9570 adapt for Asio 1.34 [3]
I applied the upstream fixes in the sandbox [4] to be able to build the
packages that depend on opendht, please consider applying these patches
to support the upcoming 3.15 version.
Happy hacking,
[1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4587773/
[2]:
https://github.com/savoirfairelinux/opendht/commit/c2d8b19380230e0e6a4f62c381978a00b3c99db2
[3]:
https://github.com/savoirfairelinux/opendht/commit/33f9570ecbe4a84845416e73c5c7eb3f3cfe8fc5
[4]: https://debusine.debian.net/debian/r-python-python3.15/
--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
From c2d8b19380230e0e6a4f62c381978a00b3c99db2 Mon Sep 17 00:00:00 2001
From: François-Simon Fauteux-Chapleau <[email protected]>
Date: Mon, 14 Apr 2025 13:25:02 -0400
Subject: [PATCH] http: fix service name resolution failure
---
src/http.cpp | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
Index: opendht/src/http.cpp
===================================================================
--- opendht.orig/src/http.cpp
+++ opendht/src/http.cpp
@@ -831,10 +831,21 @@ Resolver::add_callback(ResolverCb cb, sa
}
void
-Resolver::resolve(const std::string& host, const std::string& service)
+Resolver::resolve(const std::string& host, const std::string& serviceName)
{
- asio::ip::tcp::resolver::query query_(host, service);
- resolver_.async_resolve(query_, [this, host, service, destroyed = destroyed_]
+ auto service = serviceName;
+ // The async_resolve function used below typically relies on the contents of the
+ // /etc/services (Linux/POSIX) or c:\windows\system32\drivers\etc\services (Windows)
+ // file in order to resolve a descriptive service name into a port number. A
+ // resolution attempt that would otherwise succeed can therefore fail if the file
+ // is inaccessible or corrupted (which is rare but can happen in practice). We
+ // hardcode the port numbers for http and https to prevent this failure mode.
+ if (service == "http") {
+ service = "80";
+ } else if (service == "https") {
+ service = "443";
+ }
+ resolver_.async_resolve(host, service, [this, host, service, destroyed = destroyed_]
(const asio::error_code& ec, asio::ip::tcp::resolver::results_type endpoints)
{
if (ec == asio::error::operation_aborted or *destroyed)
From 33f9570ecbe4a84845416e73c5c7eb3f3cfe8fc5 Mon Sep 17 00:00:00 2001
From: Adrien Béraud <[email protected]>
Date: Tue, 22 Apr 2025 20:02:37 -0400
Subject: [PATCH] adapt for Asio 1.34
---
src/http.cpp | 20 ++++++++++----------
src/peer_discovery.cpp | 6 +++---
2 files changed, 13 insertions(+), 13 deletions(-)
--- a/src/http.cpp
+++ b/src/http.cpp
@@ -496,7 +496,7 @@ Connection::set_ssl_verification(const s
}
// starts from CA and goes down the presented chain
- auto verifier = asio::ssl::rfc2818_verification(hostname);
+ auto verifier = asio::ssl::host_name_verification(hostname);
bool verified = verifier(preverified, ctx);
auto verify_ec = X509_STORE_CTX_get_error(ctx.native_handle());
if (verify_ec != 0 /*X509_V_OK*/ and logger)
@@ -668,12 +668,12 @@ Connection::async_write(BytesHandlerCb c
{
std::lock_guard<std::mutex> lock(mutex_);
if (!is_open()) {
- if (cb) ctx_.post([cb](){ cb(asio::error::broken_pipe, 0); });
+ if (cb) asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); });
return;
}
if (ssl_socket_) asio::async_write(*ssl_socket_, write_buf_, wrapCallback(std::move(cb)));
else if (socket_) asio::async_write(*socket_, write_buf_, wrapCallback(std::move(cb)));
- else if (cb) ctx_.post([cb](){ cb(asio::error::operation_aborted, 0); });
+ else if (cb) asio::post(ctx_, [cb](){ cb(asio::error::operation_aborted, 0); });
}
void
@@ -681,12 +681,12 @@ Connection::async_read_until(const char*
{
std::lock_guard<std::mutex> lock(mutex_);
if (!is_open()) {
- if (cb) ctx_.post([cb](){ cb(asio::error::broken_pipe, 0); });
+ if (cb) asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); });
return;
}
if (ssl_socket_) asio::async_read_until(*ssl_socket_, read_buf_, delim, wrapCallback(std::move(cb)));
else if (socket_) asio::async_read_until(*socket_, read_buf_, delim, wrapCallback(std::move(cb)));
- else if (cb) ctx_.post([cb](){ cb(asio::error::operation_aborted, 0); });
+ else if (cb) asio::post(ctx_, [cb](){ cb(asio::error::operation_aborted, 0); });
}
void
@@ -694,12 +694,12 @@ Connection::async_read_until(char delim,
{
std::lock_guard<std::mutex> lock(mutex_);
if (!is_open()) {
- if (cb) ctx_.post([cb](){ cb(asio::error::broken_pipe, 0); });
+ if (cb) asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); });
return;
}
if (ssl_socket_) asio::async_read_until(*ssl_socket_, read_buf_, delim, wrapCallback(std::move(cb)));
else if (socket_) asio::async_read_until(*socket_, read_buf_, delim, wrapCallback(std::move(cb)));
- else if (cb) ctx_.post([cb](){ cb(asio::error::operation_aborted, 0); });
+ else if (cb) asio::post(ctx_, [cb](){ cb(asio::error::operation_aborted, 0); });
}
void
@@ -707,12 +707,12 @@ Connection::async_read(size_t bytes, Byt
{
std::lock_guard<std::mutex> lock(mutex_);
if (!is_open()) {
- if (cb) ctx_.post([cb](){ cb(asio::error::broken_pipe, 0); });
+ if (cb) asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); });
return;
}
if (ssl_socket_) asio::async_read(*ssl_socket_, read_buf_, asio::transfer_exactly(bytes), wrapCallback(std::move(cb)));
else if (socket_) asio::async_read(*socket_, read_buf_, asio::transfer_exactly(bytes), wrapCallback(std::move(cb)));
- else if (cb) ctx_.post([cb](){ cb(asio::error::operation_aborted, 0); });
+ else if (cb) asio::post(ctx_, [cb](){ cb(asio::error::operation_aborted, 0); });
}
void
@@ -720,7 +720,7 @@ Connection::async_read_some(size_t bytes
{
std::lock_guard<std::mutex> lock(mutex_);
if (!is_open()) {
- if (cb) ctx_.post([cb](){ cb(asio::error::broken_pipe, 0); });
+ if (cb) asio::post(ctx_, [cb](){ cb(asio::error::broken_pipe, 0); });
return;
}
auto buf = read_buf_.prepare(bytes);
--- a/src/peer_discovery.cpp
+++ b/src/peer_discovery.cpp
@@ -83,8 +83,8 @@ PeerDiscovery::DomainPeerDiscovery::Doma
: logger_(logger)
, ioContext_(ioContext)
, sockFd_(*ioContext_, domain)
- , sockAddrSend_(asio::ip::address::from_string(domain.family() == AF_INET ? MULTICAST_ADDRESS_IPV4
- : MULTICAST_ADDRESS_IPV6), port)
+ , sockAddrSend_(asio::ip::make_address(domain.family() == AF_INET ? MULTICAST_ADDRESS_IPV4
+ : MULTICAST_ADDRESS_IPV6), port)
{
try {
sockFd_.set_option(asio::ip::multicast::join_group(sockAddrSend_.address()));
@@ -110,7 +110,7 @@ PeerDiscovery::DomainPeerDiscovery::star
callbackmap_[type] = callback;
if (not drunning_) {
drunning_ = true;
- ioContext_->post([this] () {
+ asio::post(*ioContext_, [this] () {
loopListener();
query(sockAddrSend_);
});
@@ -216,7 +216,7 @@ PeerDiscovery::DomainPeerDiscovery::star
messages_[type] = std::move(pack_buf_c);
reloadMessages();
lrunning_ = true;
- ioContext_->post([this] () { publish(sockAddrSend_); });
+ asio::post(*ioContext_, [this] () { publish(sockAddrSend_); });
}
bool