diff --git a/src/session.cpp b/src/session.cpp index a508788ca..c31d2c03d 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -515,8 +515,8 @@ namespace libtorrent p.userdata = userdata; return add_torrent(p); } -#endif -#endif +#endif // TORRENT_NO_DEPRECATE +#endif // BOOST_NO_EXCEPTIONS void session::remove_torrent(const torrent_handle& h, int options) { @@ -736,11 +736,13 @@ namespace libtorrent int session::local_upload_rate_limit() const { + session_impl::mutex_t::scoped_lock l(m_impl->m_mutex); return m_impl->local_upload_rate_limit(); } int session::local_download_rate_limit() const { + session_impl::mutex_t::scoped_lock l(m_impl->m_mutex); return m_impl->local_download_rate_limit(); } @@ -758,11 +760,13 @@ namespace libtorrent void session::set_local_upload_rate_limit(int bytes_per_second) { + session_impl::mutex_t::scoped_lock l(m_impl->m_mutex); m_impl->set_local_upload_rate_limit(bytes_per_second); } void session::set_local_download_rate_limit(int bytes_per_second) { + session_impl::mutex_t::scoped_lock l(m_impl->m_mutex); m_impl->set_local_download_rate_limit(bytes_per_second); } @@ -798,11 +802,13 @@ namespace libtorrent void session::set_alert_dispatch(boost::function const& fun) { + // this function deliberately doesn't acquire the mutex return m_impl->set_alert_dispatch(fun); } alert const* session::wait_for_alert(time_duration max_wait) { + // this function deliberately doesn't acquire the mutex return m_impl->wait_for_alert(max_wait); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 9f0ee983a..d7c1aff89 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2683,8 +2683,6 @@ namespace aux { void session_impl::set_local_download_rate_limit(int bytes_per_second) { - mutex_t::scoped_lock l(m_mutex); - INVARIANT_CHECK; if (bytes_per_second <= 0) bytes_per_second = 0; @@ -2693,8 +2691,6 @@ namespace aux { void session_impl::set_local_upload_rate_limit(int bytes_per_second) { - mutex_t::scoped_lock l(m_mutex); - INVARIANT_CHECK; if (bytes_per_second <= 0) bytes_per_second = 0; @@ -2749,19 +2745,16 @@ namespace aux { int session_impl::local_upload_rate_limit() const { - mutex_t::scoped_lock l(m_mutex); return m_local_upload_channel.throttle(); } int session_impl::local_download_rate_limit() const { - mutex_t::scoped_lock l(m_mutex); return m_local_download_channel.throttle(); } int session_impl::upload_rate_limit() const { - mutex_t::scoped_lock l(m_mutex); return m_upload_channel.throttle(); }