mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
lt sync 2881
This commit is contained in:
parent
85e065c29d
commit
61985777da
6 changed files with 38 additions and 4 deletions
|
@ -63,6 +63,7 @@ public:
|
||||||
void limit(int limit);
|
void limit(int limit);
|
||||||
int limit() const;
|
int limit() const;
|
||||||
void close();
|
void close();
|
||||||
|
int size() const { return m_queue.size(); }
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void check_invariant() const;
|
void check_invariant() const;
|
||||||
|
@ -93,6 +94,7 @@ private:
|
||||||
int m_next_ticket;
|
int m_next_ticket;
|
||||||
int m_num_connecting;
|
int m_num_connecting;
|
||||||
int m_half_open_limit;
|
int m_half_open_limit;
|
||||||
|
bool m_abort;
|
||||||
|
|
||||||
deadline_timer m_timer;
|
deadline_timer m_timer;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace libtorrent
|
||||||
connection_queue::connection_queue(io_service& ios): m_next_ticket(0)
|
connection_queue::connection_queue(io_service& ios): m_next_ticket(0)
|
||||||
, m_num_connecting(0)
|
, m_num_connecting(0)
|
||||||
, m_half_open_limit(0)
|
, m_half_open_limit(0)
|
||||||
|
, m_abort(false)
|
||||||
, m_timer(ios)
|
, m_timer(ios)
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
, m_in_timeout_function(false)
|
, m_in_timeout_function(false)
|
||||||
|
@ -114,7 +115,24 @@ namespace libtorrent
|
||||||
void connection_queue::close()
|
void connection_queue::close()
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
mutex_t::scoped_lock l(m_mutex);
|
||||||
m_timer.cancel(ec);
|
m_timer.cancel(ec);
|
||||||
|
m_abort = true;
|
||||||
|
|
||||||
|
// make a copy of the list to go through, so
|
||||||
|
// that connections removing themseleves won't
|
||||||
|
// interfere with the iteration
|
||||||
|
std::list<entry> closing_entries = m_queue;
|
||||||
|
|
||||||
|
// we don't want to call the timeout callback while we're locked
|
||||||
|
// since that is a recepie for dead-locks
|
||||||
|
l.unlock();
|
||||||
|
|
||||||
|
for (std::list<entry>::iterator i = closing_entries.begin()
|
||||||
|
, end(closing_entries.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
try { i->on_timeout(); } catch (std::exception&) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void connection_queue::limit(int limit)
|
void connection_queue::limit(int limit)
|
||||||
|
@ -148,6 +166,7 @@ namespace libtorrent
|
||||||
#ifdef TORRENT_CONNECTION_LOGGING
|
#ifdef TORRENT_CONNECTION_LOGGING
|
||||||
m_log << log_time() << " " << free_slots() << std::endl;
|
m_log << log_time() << " " << free_slots() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
if (m_abort) return;
|
||||||
|
|
||||||
if (m_num_connecting >= m_half_open_limit
|
if (m_num_connecting >= m_half_open_limit
|
||||||
&& m_half_open_limit > 0) return;
|
&& m_half_open_limit > 0) return;
|
||||||
|
|
|
@ -495,6 +495,12 @@ namespace aux {
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << time_now_string() << " aborting all connections (" << m_connections.size() << ")\n";
|
(*m_logger) << time_now_string() << " aborting all connections (" << m_connections.size() << ")\n";
|
||||||
#endif
|
#endif
|
||||||
|
m_half_open.close();
|
||||||
|
|
||||||
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
|
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// abort all connections
|
// abort all connections
|
||||||
while (!m_connections.empty())
|
while (!m_connections.empty())
|
||||||
{
|
{
|
||||||
|
@ -505,10 +511,14 @@ namespace aux {
|
||||||
TORRENT_ASSERT(conn == int(m_connections.size()) + 1);
|
TORRENT_ASSERT(conn == int(m_connections.size()) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
|
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << std::endl;
|
||||||
|
#endif
|
||||||
|
TORRENT_ASSERT(m_half_open.size() == 0);
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << time_now_string() << " shutting down connection queue\n";
|
(*m_logger) << time_now_string() << " shutting down connection queue\n";
|
||||||
#endif
|
#endif
|
||||||
m_half_open.close();
|
|
||||||
|
|
||||||
m_download_channel.close();
|
m_download_channel.close();
|
||||||
m_upload_channel.close();
|
m_upload_channel.close();
|
||||||
|
@ -2178,6 +2188,7 @@ namespace aux {
|
||||||
(*m_logger) << time_now_string() << "\n\n *** shutting down session *** \n\n";
|
(*m_logger) << time_now_string() << "\n\n *** shutting down session *** \n\n";
|
||||||
#endif
|
#endif
|
||||||
abort();
|
abort();
|
||||||
|
TORRENT_ASSERT(m_connections.empty());
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_GEO_IP
|
#ifndef TORRENT_DISABLE_GEO_IP
|
||||||
if (m_asnum_db) GeoIP_delete(m_asnum_db);
|
if (m_asnum_db) GeoIP_delete(m_asnum_db);
|
||||||
|
@ -2200,6 +2211,7 @@ namespace aux {
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << time_now_string() << " shutdown complete!\n";
|
(*m_logger) << time_now_string() << " shutdown complete!\n";
|
||||||
#endif
|
#endif
|
||||||
|
TORRENT_ASSERT(m_connections.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::set_max_uploads(int limit)
|
void session_impl::set_max_uploads(int limit)
|
||||||
|
|
|
@ -525,7 +525,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_WPATH
|
#if TORRENT_USE_WPATH
|
||||||
fs::wpath file_path = safe_convert(m_save_path / file_iter->path);
|
fs::wpath file_path = safe_convert((m_save_path / file_iter->path).string());
|
||||||
#else
|
#else
|
||||||
fs::path file_path = m_save_path / file_iter->path;
|
fs::path file_path = m_save_path / file_iter->path;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3078,7 +3078,8 @@ namespace libtorrent
|
||||||
&& m_state != torrent_status::checking_files
|
&& m_state != torrent_status::checking_files
|
||||||
&& (m_state != torrent_status::queued_for_checking
|
&& (m_state != torrent_status::queued_for_checking
|
||||||
|| !valid_metadata())
|
|| !valid_metadata())
|
||||||
&& m_policy.num_connect_candidates() > 0;
|
&& m_policy.num_connect_candidates() > 0
|
||||||
|
&& !m_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::disconnect_all()
|
void torrent::disconnect_all()
|
||||||
|
|
|
@ -160,7 +160,7 @@ int upnp::add_mapping(upnp::protocol_type p, int external_port, int local_port)
|
||||||
m_log << time_now_string()
|
m_log << time_now_string()
|
||||||
<< " *** add mapping [ proto: " << (p == tcp?"tcp":"udp")
|
<< " *** add mapping [ proto: " << (p == tcp?"tcp":"udp")
|
||||||
<< " ext_port: " << external_port
|
<< " ext_port: " << external_port
|
||||||
<< " local_port:" << local_port << " ]";
|
<< " local_port :" << local_port << " ]";
|
||||||
if (m_disabled) m_log << " DISABLED";
|
if (m_disabled) m_log << " DISABLED";
|
||||||
m_log << std::endl;
|
m_log << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue