-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow execution of on_unknown_torrent
method in the absence of active torrents
#7537
allow execution of on_unknown_torrent
method in the absence of active torrents
#7537
Conversation
958c000
to
f775cd2
Compare
I would prefer to keep optimized cases (early exits) in the common case, where there's no plugin. What do you think of adding another feature flag letting the plugin request having i.e. add another flag here: https://github.com/arvidn/libtorrent/blob/RC_2_0/include/libtorrent/extensions.hpp#L198-L212 And instead of removing those checks, only disregard them if at least one plugin has requested this feature. |
62c4c27
to
d8cd467
Compare
@arvidn |
on_unknown_torrent is called when a connection is made to a torrent that is not found in the session, allowing extensions to determine whether or not a torrent should be added to the session. |
How can this be possible? Could you describe the appropriate scenario? |
if you want to simulate this you need 2 sessions you add a torrent to one of them and from the torrent_handle you connect to the other session (via the listening port). th = session.add_torrent(atp);
th.connect_peer(lt::tcp::endpoint(lt::make_address(ip), port)); the other session will receive a new connection and attempt to attach it to a torrent: |
I asked about supposed real scenario. Shouldn't peer query for torrent only those peers that announced that torrent in any way? |
this is useful if you don't want to keep the torrents in the session but put them back if a peer tries to connect to you for a torrent you previously announced. |
What's the point? (I'm just trying to figure out if there is any tangible benefit from this approach. Or maybe it's just related to some very specific use case.) |
You can always continue to manually announce a torrent in the dht (session_handle::dht_announce) (I don't know if there is a lifetime for other announcements like lsd, tracker). This may make it possible not to use resources unnecessarily (keep torrents inactive in the session). This pull request is only intended to make this function already existing in the case where there is no torrent in the session (before this pull request if you already had an active torrent in your session if a peer tried to connect to a torrent that you did not have in the session the call to on_unknown_torrent would have been made). |
👍 |
6db2ad3
to
9b08bb6
Compare
@joriscarrier does this compile for you?
|
One example is if you seed more torrents than you can have active in the session (say, many millions), you can decide to load and add a torrents to the session on-demand. Another example might be a crawler, that just wants to index any torrents it learns about, it might want to add the torrent (as a magnet link). |
@joriscarrier it looks like the extension code isn't wrapped in the appropriate |
9456caa
to
6da92f7
Compare
I didn't check if TORRENT_DISABLE_EXTENSIONS was defined or not. I updated it like this: bool want_on_unknown_torrent = false;
#ifndef TORRENT_DISABLE_EXTENSIONS
want_on_unknown_torrent = !m_ses_extensions[plugins_unknown_torrent_idx].empty();
#endif |
6da92f7
to
80cd560
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. there should be an entry in the changelog too. especially since it changes behavior of plugins
80cd560
to
6b644a7
Compare
I re-triggered CI on top of the latest version of |
No description provided.