Skip to content

Commit

Permalink
allow execution of on_unknown_torrent method in the absence of acti…
Browse files Browse the repository at this point in the history
…ve torrents
  • Loading branch information
joriscarrier committed Oct 27, 2023
1 parent 5ce4c51 commit 958c000
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions src/session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Copyright (c) 2020, Fonic
Copyright (c) 2020, Paul-Louis Ageneau
Copyright (c) 2022, Vladimir Golovnev (glassez)
Copyright (c) 2022, thrnz
Copyright (c) 2023, Joris Carrier
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -3084,16 +3085,6 @@ namespace {
return;
}

// check if we have any active torrents
// if we don't reject the connection
if (m_torrents.empty())
{
#ifndef TORRENT_DISABLE_LOGGING
session_log("<== INCOMING CONNECTION [ rejected, there are no torrents ]");
#endif
return;
}

// figure out which peer classes this is connections has,
// to get connection_limit_factor
peer_class_set pcs;
Expand Down Expand Up @@ -3135,25 +3126,6 @@ namespace {
return;
}

// if we don't have any active torrents, there's no
// point in accepting this connection. If, however,
// the setting to start up queued torrents when they
// get an incoming connection is enabled, we cannot
// perform this check.
if (!m_settings.get_bool(settings_pack::incoming_starts_queued_torrents))
{
bool has_active_torrent = std::any_of(m_torrents.begin(), m_torrents.end()
, [](std::shared_ptr<torrent> const& i)
{ return !i->is_torrent_paused(); });
if (!has_active_torrent)
{
#ifndef TORRENT_DISABLE_LOGGING
session_log("<== INCOMING CONNECTION [ rejected, no active torrents ]");
#endif
return;
}
}

m_stats_counters.inc_stats_counter(counters::incoming_connections);

if (m_alerts.should_post<incoming_connection_alert>())
Expand Down

0 comments on commit 958c000

Please sign in to comment.