From 20aa53953cb7b356dba403e59c0a0cf8588961ce Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 7 Apr 2015 00:50:21 +0000 Subject: [PATCH] fix etensions being passed all alerts --- include/libtorrent/alert_manager.hpp | 4 ++-- .../libtorrent/aux_/alert_manager_variadic_emplace.hpp | 3 +-- src/alert_manager.cpp | 10 ++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/libtorrent/alert_manager.hpp b/include/libtorrent/alert_manager.hpp index 8dfb475ef..a6481f75c 100644 --- a/include/libtorrent/alert_manager.hpp +++ b/include/libtorrent/alert_manager.hpp @@ -87,7 +87,7 @@ namespace libtorrent { T alert(m_allocations[m_generation], std::forward(args)...); m_alerts[m_generation].push_back(alert); - maybe_notify(lock); + maybe_notify(&alert, lock); } #else @@ -157,7 +157,7 @@ namespace libtorrent { alert_manager(alert_manager const&); alert_manager& operator=(alert_manager const&); - void maybe_notify(mutex::scoped_lock& lock); + void maybe_notify(alert* a, mutex::scoped_lock& lock); mutable mutex m_mutex; condition_variable m_condition; diff --git a/include/libtorrent/aux_/alert_manager_variadic_emplace.hpp b/include/libtorrent/aux_/alert_manager_variadic_emplace.hpp index e65cfa2eb..383eb5d2c 100644 --- a/include/libtorrent/aux_/alert_manager_variadic_emplace.hpp +++ b/include/libtorrent/aux_/alert_manager_variadic_emplace.hpp @@ -1,6 +1,5 @@ #if !BOOST_PP_IS_ITERATING - // set-up iteration #include @@ -47,7 +46,7 @@ BOOST_PP_ENUM_PARAMS(I, a)); m_alerts[m_generation].push_back(alert); - maybe_notify(lock); + maybe_notify(&alert, lock); } #undef I diff --git a/src/alert_manager.cpp b/src/alert_manager.cpp index f75e3f4fb..43606fe1a 100644 --- a/src/alert_manager.cpp +++ b/src/alert_manager.cpp @@ -71,9 +71,15 @@ namespace libtorrent return NULL; } - void alert_manager::maybe_notify(mutex::scoped_lock& lock) + void alert_manager::maybe_notify(alert* a, mutex::scoped_lock& lock) { - +#ifndef TORRENT_DISABLE_EXTENSIONS + for (ses_extension_list_t::iterator i = m_ses_extensions.begin() + , end(m_ses_extensions.end()); i != end; ++i) + { + (*i)->on_alert(a); + } +#endif if (m_alerts[m_generation].size() == 1) { lock.unlock();