session_impl and connection_queue fixes
This commit is contained in:
parent
1b6a8925eb
commit
1abb7c161d
|
@ -384,4 +384,3 @@ namespace libtorrent
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
#include "libtorrent/socket.hpp"
|
#include "libtorrent/socket.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
|
@ -88,6 +89,10 @@ private:
|
||||||
int m_half_open_limit;
|
int m_half_open_limit;
|
||||||
|
|
||||||
deadline_timer m_timer;
|
deadline_timer m_timer;
|
||||||
|
|
||||||
|
typedef boost::recursive_mutex mutex_t;
|
||||||
|
mutable mutex_t m_mutex;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool m_in_timeout_function;
|
bool m_in_timeout_function;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -456,4 +456,3 @@ namespace libtorrent
|
||||||
|
|
||||||
#endif // TORRENT_PIECE_PICKER_HPP_INCLUDED
|
#endif // TORRENT_PIECE_PICKER_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace libtorrent
|
||||||
, boost::function<void()> const& on_timeout
|
, boost::function<void()> const& on_timeout
|
||||||
, time_duration timeout)
|
, time_duration timeout)
|
||||||
{
|
{
|
||||||
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
m_queue.push_back(entry());
|
m_queue.push_back(entry());
|
||||||
|
@ -68,6 +70,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void connection_queue::done(int ticket)
|
void connection_queue::done(int ticket)
|
||||||
{
|
{
|
||||||
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
std::list<entry>::iterator i = std::find_if(m_queue.begin()
|
std::list<entry>::iterator i = std::find_if(m_queue.begin()
|
||||||
|
@ -105,6 +109,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void connection_queue::try_connect()
|
void connection_queue::try_connect()
|
||||||
{
|
{
|
||||||
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (!free_slots() || m_queue.empty())
|
if (!free_slots() || m_queue.empty())
|
||||||
|
@ -148,6 +154,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void connection_queue::on_timeout(asio::error_code const& e)
|
void connection_queue::on_timeout(asio::error_code const& e)
|
||||||
{
|
{
|
||||||
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
function_guard guard_(m_in_timeout_function);
|
function_guard guard_(m_in_timeout_function);
|
||||||
|
|
|
@ -3003,4 +3003,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1789,4 +1789,3 @@ namespace libtorrent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1239,7 +1239,8 @@ namespace detail
|
||||||
if (num_connections() >= max_connections() && !m_torrents.empty())
|
if (num_connections() >= max_connections() && !m_torrents.empty())
|
||||||
{
|
{
|
||||||
torrent_map::iterator i = std::max_element(m_torrents.begin(), m_torrents.end()
|
torrent_map::iterator i = std::max_element(m_torrents.begin(), m_torrents.end()
|
||||||
, bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _1)));
|
, bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _1))
|
||||||
|
< bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _2)));
|
||||||
|
|
||||||
assert(i != m_torrents.end());
|
assert(i != m_torrents.end());
|
||||||
i->second->get_policy().disconnect_one_peer();
|
i->second->get_policy().disconnect_one_peer();
|
||||||
|
|
Loading…
Reference in New Issue