From dd48faa8d482162435ddba75ffdb4698e610b701 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 8 Feb 2016 02:05:00 -0500 Subject: [PATCH] minor debug logging issue in test facility wait-for-alert and fix minor shutdown issue with udp_socket packet subscription --- src/session_impl.cpp | 4 +++- src/torrent.cpp | 9 +++++++++ test/setup_transfer.cpp | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 15495bb56..b642688e6 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5924,7 +5924,7 @@ retry: #ifdef TORRENT_USE_OPENSSL m_ssl_udp_socket.unsubscribe(this); - m_ssl_udp_socket.unsubscribe(&m_utp_socket_manager); + m_ssl_udp_socket.unsubscribe(&m_ssl_utp_socket_manager); #endif TORRENT_ASSERT(m_torrents.empty()); @@ -6048,6 +6048,8 @@ retry: } #endif + // TODO: 2 this should be factored into the udp socket, so we only have the + // code once void session_impl::update_peer_tos() { error_code ec; diff --git a/src/torrent.cpp b/src/torrent.cpp index fa35d0c4b..af4c245ee 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6009,18 +6009,27 @@ namespace libtorrent if (alerts().should_post()) alerts().emplace_alert(get_handle(), ec, certificate); } +#ifndef TORRENT_DISABLE_LOGGING + debug_log("*** use certificate file: %s", ec.message().c_str()); +#endif m_ssl_ctx->use_private_key_file(private_key, context::pem, ec); if (ec) { if (alerts().should_post()) alerts().emplace_alert(get_handle(), ec, private_key); } +#ifndef TORRENT_DISABLE_LOGGING + debug_log("*** use private key file: %s", ec.message().c_str()); +#endif m_ssl_ctx->use_tmp_dh_file(dh_params, ec); if (ec) { if (alerts().should_post()) alerts().emplace_alert(get_handle(), ec, dh_params); } +#ifndef TORRENT_DISABLE_LOGGING + debug_log("*** use DH file: %s", ec.message().c_str()); +#endif } void torrent::set_ssl_cert_buffer(std::string const& certificate diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 6f8a4af8c..209ab1468 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -155,6 +155,8 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name) time_point now = clock_type::now(); if (now > end) return NULL; + alert const* ret = NULL; + ses.wait_for_alert(end - now); std::vector alerts; ses.pop_alerts(&alerts); @@ -163,11 +165,12 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name) { fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name , (*i)->what(), (*i)->message().c_str()); - if ((*i)->type() == type) + if ((*i)->type() == type && !ret) { - return *i; + ret = *i; } } + if (ret) return ret; } return NULL; }