mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
lt sync 2881
This commit is contained in:
parent
85e065c29d
commit
61985777da
@ -63,6 +63,7 @@ public:
|
||||
void limit(int limit);
|
||||
int limit() const;
|
||||
void close();
|
||||
int size() const { return m_queue.size(); }
|
||||
|
||||
#ifndef NDEBUG
|
||||
void check_invariant() const;
|
||||
@ -93,6 +94,7 @@ private:
|
||||
int m_next_ticket;
|
||||
int m_num_connecting;
|
||||
int m_half_open_limit;
|
||||
bool m_abort;
|
||||
|
||||
deadline_timer m_timer;
|
||||
|
||||
|
@ -42,6 +42,7 @@ namespace libtorrent
|
||||
connection_queue::connection_queue(io_service& ios): m_next_ticket(0)
|
||||
, m_num_connecting(0)
|
||||
, m_half_open_limit(0)
|
||||
, m_abort(false)
|
||||
, m_timer(ios)
|
||||
#ifndef NDEBUG
|
||||
, m_in_timeout_function(false)
|
||||
@ -114,7 +115,24 @@ namespace libtorrent
|
||||
void connection_queue::close()
|
||||
{
|
||||
error_code ec;
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
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)
|
||||
@ -148,6 +166,7 @@ namespace libtorrent
|
||||
#ifdef TORRENT_CONNECTION_LOGGING
|
||||
m_log << log_time() << " " << free_slots() << std::endl;
|
||||
#endif
|
||||
if (m_abort) return;
|
||||
|
||||
if (m_num_connecting >= m_half_open_limit
|
||||
&& m_half_open_limit > 0) return;
|
||||
|
@ -495,6 +495,12 @@ namespace aux {
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " aborting all connections (" << m_connections.size() << ")\n";
|
||||
#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
|
||||
while (!m_connections.empty())
|
||||
{
|
||||
@ -505,10 +511,14 @@ namespace aux {
|
||||
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)
|
||||
(*m_logger) << time_now_string() << " shutting down connection queue\n";
|
||||
#endif
|
||||
m_half_open.close();
|
||||
|
||||
m_download_channel.close();
|
||||
m_upload_channel.close();
|
||||
@ -2178,6 +2188,7 @@ namespace aux {
|
||||
(*m_logger) << time_now_string() << "\n\n *** shutting down session *** \n\n";
|
||||
#endif
|
||||
abort();
|
||||
TORRENT_ASSERT(m_connections.empty());
|
||||
|
||||
#ifndef TORRENT_DISABLE_GEO_IP
|
||||
if (m_asnum_db) GeoIP_delete(m_asnum_db);
|
||||
@ -2200,6 +2211,7 @@ namespace aux {
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " shutdown complete!\n";
|
||||
#endif
|
||||
TORRENT_ASSERT(m_connections.empty());
|
||||
}
|
||||
|
||||
void session_impl::set_max_uploads(int limit)
|
||||
|
@ -525,7 +525,7 @@ namespace libtorrent
|
||||
#endif
|
||||
|
||||
#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
|
||||
fs::path file_path = m_save_path / file_iter->path;
|
||||
#endif
|
||||
|
@ -3078,7 +3078,8 @@ namespace libtorrent
|
||||
&& m_state != torrent_status::checking_files
|
||||
&& (m_state != torrent_status::queued_for_checking
|
||||
|| !valid_metadata())
|
||||
&& m_policy.num_connect_candidates() > 0;
|
||||
&& m_policy.num_connect_candidates() > 0
|
||||
&& !m_abort;
|
||||
}
|
||||
|
||||
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()
|
||||
<< " *** add mapping [ proto: " << (p == tcp?"tcp":"udp")
|
||||
<< " ext_port: " << external_port
|
||||
<< " local_port:" << local_port << " ]";
|
||||
<< " local_port :" << local_port << " ]";
|
||||
if (m_disabled) m_log << " DISABLED";
|
||||
m_log << std::endl;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user