Giter Club home page Giter Club logo

Comments (8)

atomashpolskiy avatar atomashpolskiy commented on May 22, 2024

What do you mean by "one peer"? Peer in Bt is synonymous with a TCP socket, so there physically can't be two different connections. If some peer is serving more than one torrent, then the connection initiator will have to choose which one torrent he wants to download from this peer.

from bt.

ckovorodkin avatar ckovorodkin commented on May 22, 2024

Peer in Bt is synonymous with a TCP socket, so there physically can't be two different connections.

Really? How about outgoing connections? #63 (comment)

If some peer is serving more than one torrent, then the connection initiator will have to choose which one torrent he wants to download from this peer.

Seams like BT have no 'connection initiator that choose which one torrent he wants to download from this peer'

But uTorrent can upload many-to-one and can download many torrents from one peer. It is quite common situation (in 2018).

from bt.

atomashpolskiy avatar atomashpolskiy commented on May 22, 2024

Yeah, seems like you're right. It looks like we will establish the connection and then immediately close it IF we're already downloading something from the same peer. Is it correct?

But uTorrent can upload many-to-one

Seems like we can do this too) Need to support many-from-one though

from bt.

ckovorodkin avatar ckovorodkin commented on May 22, 2024

It looks like we will establish the connection and then immediately close it IF we're already downloading something from the same peer. Is it correct?

Yes, and use instead of closed connection another one that related to different torrent

if (connectionResult.isSuccess()) {
PeerConnection established = connectionResult.getConnection();
PeerConnection added = connectionPool.addConnectionIfAbsent(established);
if (added != established) {
established.closeQuietly();
}
return ConnectionResult.success(added);

It is dangerous malfunction.

The root problem in

but mapping don't use TorrentId as a part of the key:

private ConcurrentMap<Peer, PeerConnection> connections;

from bt.

atomashpolskiy avatar atomashpolskiy commented on May 22, 2024

Seems like we need to:

  • change bt.net.PeerConnectionPool#getConnection(Peer) to bt.net.PeerConnectionPool#getConnection(Peer, TorrentId)
  • update bt.net.PeerConnectionPool#addConnectionIfAbsent and everything down the line in this class to respect the connection's torrent ID

from bt.

ckovorodkin avatar ckovorodkin commented on May 22, 2024

Please recheck this: if (success) { -> if (removed != null) {
39d5d67#r27713125

alternatively:
boolean success = (removed == connection); -> boolean success = (removed != null);

from bt.

ckovorodkin avatar ckovorodkin commented on May 22, 2024

Please review this: 39d5d67#r27713306 39d5d67#r27713302

synchronized (modificationLock) {...} -> continue; // update in progress. We'll see it later.

Let's do add/remove/cleanup work in dedicated methods.

from bt.

ckovorodkin avatar ckovorodkin commented on May 22, 2024

It is necessary to check the duplicate that occurs after the peer is reconnected.
39d5d67#r27773319
39d5d67#r27773326

To prevent double (... triple, ets) message processing.

from bt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.