merged fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-11-02 23:08:26 +00:00
parent 0f298dbe88
commit 5812e8415d
5 changed files with 20 additions and 7 deletions

View File

@ -25,6 +25,7 @@
* fix uTP edge case where udp socket buffer fills up * fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP * fix nagle implementation in uTP
* fix deadlock caused by some UDP tracker failures
* fix potential integer overflow issue in timers on windows * fix potential integer overflow issue in timers on windows
* minor fix to peer_proportional mixed_mode algorithm (TCP limit could go too low) * minor fix to peer_proportional mixed_mode algorithm (TCP limit could go too low)
* graceful pause fix * graceful pause fix

View File

@ -188,6 +188,8 @@ namespace libtorrent
virtual void on_timeout(error_code const& ec) = 0; virtual void on_timeout(error_code const& ec) = 0;
virtual ~timeout_handler() {} virtual ~timeout_handler() {}
io_service& get_io_service() { return m_timeout.get_io_service(); }
#if !defined TORRENT_VERBOSE_LOGGING \ #if !defined TORRENT_VERBOSE_LOGGING \
&& !defined TORRENT_LOGGING \ && !defined TORRENT_LOGGING \
&& !defined TORRENT_ERROR_LOGGING && !defined TORRENT_ERROR_LOGGING
@ -229,7 +231,6 @@ namespace libtorrent
tracker_request const& tracker_req() const { return m_req; } tracker_request const& tracker_req() const { return m_req; }
void fail_disp(error_code ec) { fail(ec); }
void fail(error_code const& ec, int code = -1, char const* msg = "" void fail(error_code const& ec, int code = -1, char const* msg = ""
, int interval = 0, int min_interval = 0); , int interval = 0, int min_interval = 0);
virtual void start() = 0; virtual void start() = 0;
@ -242,6 +243,9 @@ namespace libtorrent
virtual bool on_receive_hostname(error_code const& ec, char const* hostname virtual bool on_receive_hostname(error_code const& ec, char const* hostname
, char const* buf, int size) { return false; } , char const* buf, int size) { return false; }
boost::intrusive_ptr<tracker_connection> self()
{ return boost::intrusive_ptr<tracker_connection>(this); }
#if !defined TORRENT_VERBOSE_LOGGING \ #if !defined TORRENT_VERBOSE_LOGGING \
&& !defined TORRENT_LOGGING \ && !defined TORRENT_LOGGING \
&& !defined TORRENT_ERROR_LOGGING && !defined TORRENT_ERROR_LOGGING
@ -249,6 +253,9 @@ namespace libtorrent
protected: protected:
#endif #endif
void fail_impl(error_code const& ec, int code = -1, std::string msg = std::string()
, int interval = 0, int min_interval = 0);
boost::weak_ptr<request_callback> m_requester; boost::weak_ptr<request_callback> m_requester;
tracker_manager& m_man; tracker_manager& m_man;

View File

@ -107,8 +107,7 @@ namespace libtorrent
std::size_t pos = url.find("announce"); std::size_t pos = url.find("announce");
if (pos == std::string::npos) if (pos == std::string::npos)
{ {
m_ios.post(boost::bind(&http_tracker_connection::fail_disp, self() tracker_connection::fail(error_code(errors::scrape_not_available));
, error_code(errors::scrape_not_available)));
return; return;
} }
url.replace(pos, 8, "scrape"); url.replace(pos, 8, "scrape");

View File

@ -163,9 +163,17 @@ namespace libtorrent
void tracker_connection::fail(error_code const& ec, int code void tracker_connection::fail(error_code const& ec, int code
, char const* msg, int interval, int min_interval) , char const* msg, int interval, int min_interval)
{
// we need to post the error to avoid deadlock
get_io_service().post(boost::bind(&tracker_connection::fail_impl
, self(), ec, code, std::string(msg), interval, min_interval));
}
void tracker_connection::fail_impl(error_code const& ec, int code
, std::string msg, int interval, int min_interval)
{ {
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
if (cb) cb->tracker_request_error(m_req, code, ec, msg if (cb) cb->tracker_request_error(m_req, code, ec, msg.c_str()
, interval == 0 ? min_interval : interval); , interval == 0 ? min_interval : interval);
close(); close();
} }

View File

@ -95,9 +95,7 @@ namespace libtorrent
if (ec) if (ec)
{ {
// never call fail() when the session mutex is locked! tracker_connection::fail(ec);
m_ses.m_io_service.post(boost::bind(
&tracker_connection::fail_disp, self(), ec));
return; return;
} }