diff --git a/libtorrent/src/manager.cc b/libtorrent/src/manager.cc index 88aed983..ea626143 100644 --- a/libtorrent/src/manager.cc +++ b/libtorrent/src/manager.cc @@ -102,6 +102,7 @@ Manager::Manager() : std::bind(&DownloadManager::find_main, m_downloadManager, std::placeholders::_1); m_handshakeManager->slot_download_obfuscated() = std::bind(&DownloadManager::find_main_obfuscated, m_downloadManager, std::placeholders::_1); + m_handshakeManager->slot_succeeded() = std::bind(&HandshakeManager::receive_succeeded, m_handshakeManager, std::placeholders::_1); m_connectionManager->listen()->slot_accepted() = std::bind(&HandshakeManager::add_incoming, m_handshakeManager, std::placeholders::_1, std::placeholders::_2); diff --git a/libtorrent/src/protocol/handshake.cc b/libtorrent/src/protocol/handshake.cc index e280222d..0019b46c 100644 --- a/libtorrent/src/protocol/handshake.cc +++ b/libtorrent/src/protocol/handshake.cc @@ -855,7 +855,7 @@ Handshake::event_read() { } } catch (handshake_succeeded& e) { - m_manager->receive_succeeded(this); + m_manager->call_slot_succeeded(this); } catch (handshake_error& e) { m_manager->receive_failed(this, e.type(), e.error()); @@ -962,7 +962,7 @@ Handshake::event_write() { } } catch (handshake_succeeded& e) { - m_manager->receive_succeeded(this); + m_manager->call_slot_succeeded(this); } catch (handshake_error& e) { m_manager->receive_failed(this, e.type(), e.error()); diff --git a/libtorrent/src/protocol/handshake_manager.cc b/libtorrent/src/protocol/handshake_manager.cc index 0c3dd600..b47a4485 100644 --- a/libtorrent/src/protocol/handshake_manager.cc +++ b/libtorrent/src/protocol/handshake_manager.cc @@ -93,6 +93,11 @@ HandshakeManager::erase(Handshake* handshake) { base_type::erase(itr); } +void +HandshakeManager::call_slot_succeeded(Handshake* h) { + m_slot_succeeded(h); +} + struct handshake_manager_equal : std::binary_function { bool operator () (const rak::socket_address* sa1, const Handshake* p2) const { return p2->peer_info() != NULL && *sa1 == *rak::socket_address::cast_from(p2->peer_info()->socket_address()); diff --git a/libtorrent/src/protocol/handshake_manager.h b/libtorrent/src/protocol/handshake_manager.h index cfd52aa0..2ced49c6 100644 --- a/libtorrent/src/protocol/handshake_manager.h +++ b/libtorrent/src/protocol/handshake_manager.h @@ -60,6 +60,7 @@ class HandshakeManager : private rak::unordered_vector { typedef uint32_t size_type; typedef std::function slot_download; + typedef std::function slot_handshake; // Do not connect to peers with this many or more failed chunks. static const unsigned int max_failed = 3; @@ -84,12 +85,14 @@ class HandshakeManager : private rak::unordered_vector { slot_download& slot_download_id() { return m_slot_download_id; } slot_download& slot_download_obfuscated() { return m_slot_download_obfuscated; } + slot_handshake& slot_succeeded() { return m_slot_succeeded; } // This needs to be filterable slot. DownloadMain* download_info(const char* hash) { return m_slot_download_id(hash); } DownloadMain* download_info_obfuscated(const char* hash) { return m_slot_download_obfuscated(hash); } void receive_succeeded(Handshake* h); + void call_slot_succeeded(Handshake* h); void receive_failed(Handshake* h, int message, int error); void receive_timeout(Handshake* h); @@ -105,6 +108,7 @@ class HandshakeManager : private rak::unordered_vector { slot_download m_slot_download_id; slot_download m_slot_download_obfuscated; + slot_handshake m_slot_succeeded; }; }