mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
(trunk libT) undo today's earlier commit r9381 for #2508 -- looks like I introduced a bug into the patch.
This commit is contained in:
@@ -275,7 +275,7 @@ peerCompare( const void * va, const void * vb )
|
|||||||
const tr_peer * a = va;
|
const tr_peer * a = va;
|
||||||
const tr_peer * b = vb;
|
const tr_peer * b = vb;
|
||||||
|
|
||||||
return tr_compareAddresses( &a->atom->addr, &b->atom->addr );
|
return tr_compareAddresses( &a->addr, &b->addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -283,7 +283,7 @@ peerCompareToAddr( const void * va, const void * vb )
|
|||||||
{
|
{
|
||||||
const tr_peer * a = va;
|
const tr_peer * a = va;
|
||||||
|
|
||||||
return tr_compareAddresses( &a->atom->addr, vb );
|
return tr_compareAddresses( &a->addr, vb );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tr_peer*
|
static tr_peer*
|
||||||
@@ -319,9 +319,12 @@ peerIsInUse( const Torrent * ct,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static tr_peer*
|
static tr_peer*
|
||||||
peerConstructor( void )
|
peerConstructor( const tr_address * addr )
|
||||||
{
|
{
|
||||||
return tr_new0( tr_peer, 1 );
|
tr_peer * p;
|
||||||
|
p = tr_new0( tr_peer, 1 );
|
||||||
|
p->addr = *addr;
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static tr_peer*
|
static tr_peer*
|
||||||
@@ -336,7 +339,7 @@ getPeer( Torrent * torrent,
|
|||||||
|
|
||||||
if( peer == NULL )
|
if( peer == NULL )
|
||||||
{
|
{
|
||||||
peer = peerConstructor( );
|
peer = peerConstructor( addr );
|
||||||
tr_ptrArrayInsertSorted( &torrent->peers, peer, peerCompare );
|
tr_ptrArrayInsertSorted( &torrent->peers, peer, peerCompare );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -921,14 +924,15 @@ static void
|
|||||||
addStrike( Torrent * t, tr_peer * peer )
|
addStrike( Torrent * t, tr_peer * peer )
|
||||||
{
|
{
|
||||||
tordbg( t, "increasing peer %s strike count to %d",
|
tordbg( t, "increasing peer %s strike count to %d",
|
||||||
tr_atomAddrStr( peer->atom ), peer->strikes + 1 );
|
tr_peerIoAddrStr( &peer->addr,
|
||||||
|
peer->port ), peer->strikes + 1 );
|
||||||
|
|
||||||
if( ++peer->strikes >= MAX_BAD_PIECES_PER_PEER )
|
if( ++peer->strikes >= MAX_BAD_PIECES_PER_PEER )
|
||||||
{
|
{
|
||||||
struct peer_atom * atom = peer->atom;
|
struct peer_atom * atom = peer->atom;
|
||||||
atom->myflags |= MYFLAG_BANNED;
|
atom->myflags |= MYFLAG_BANNED;
|
||||||
peer->doPurge = 1;
|
peer->doPurge = 1;
|
||||||
tordbg( t, "banning peer %s", tr_atomAddrStr( atom ) );
|
tordbg( t, "banning peer %s", tr_peerIoAddrStr( &atom->addr, atom->port ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,7 +1104,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt )
|
|||||||
{
|
{
|
||||||
struct peer_atom * atom = peer->atom;
|
struct peer_atom * atom = peer->atom;
|
||||||
if( e->progress >= 1.0 ) {
|
if( e->progress >= 1.0 ) {
|
||||||
tordbg( t, "marking peer %s as a seed", tr_atomAddrStr( atom ) );
|
tordbg( t, "marking peer %s as a seed", tr_peerIoAddrStr( &atom->addr, atom->port ) );
|
||||||
atom->flags |= ADDED_F_SEED_FLAG;
|
atom->flags |= ADDED_F_SEED_FLAG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1167,7 +1171,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt )
|
|||||||
/* some protocol error from the peer */
|
/* some protocol error from the peer */
|
||||||
peer->doPurge = 1;
|
peer->doPurge = 1;
|
||||||
tordbg( t, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error",
|
tordbg( t, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error",
|
||||||
tr_atomAddrStr( peer->atom ) );
|
tr_peerIoAddrStr( &peer->addr, peer->port ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1200,7 +1204,7 @@ ensureAtomExists( Torrent * t,
|
|||||||
a->port = port;
|
a->port = port;
|
||||||
a->flags = flags;
|
a->flags = flags;
|
||||||
a->from = from;
|
a->from = from;
|
||||||
tordbg( t, "got a new atom: %s", tr_atomAddrStr( a ) );
|
tordbg( t, "got a new atom: %s", tr_peerIoAddrStr( &a->addr, a->port ) );
|
||||||
tr_ptrArrayInsertSorted( &t->pool, a, comparePeerAtoms );
|
tr_ptrArrayInsertSorted( &t->pool, a, comparePeerAtoms );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1276,7 +1280,8 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
|||||||
|
|
||||||
if( atom->myflags & MYFLAG_BANNED )
|
if( atom->myflags & MYFLAG_BANNED )
|
||||||
{
|
{
|
||||||
tordbg( t, "banned peer %s tried to reconnect", tr_atomAddrStr( atom ) );
|
tordbg( t, "banned peer %s tried to reconnect",
|
||||||
|
tr_peerIoAddrStr( &atom->addr, atom->port ) );
|
||||||
}
|
}
|
||||||
else if( tr_peerIoIsIncoming( io )
|
else if( tr_peerIoIsIncoming( io )
|
||||||
&& ( getPeerCount( t ) >= getMaxPeerCount( t->tor ) ) )
|
&& ( getPeerCount( t ) >= getMaxPeerCount( t->tor ) ) )
|
||||||
@@ -1303,6 +1308,7 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
|||||||
peer->client = tr_strdup( client );
|
peer->client = tr_strdup( client );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peer->port = port;
|
||||||
peer->atom = atom;
|
peer->atom = atom;
|
||||||
peer->io = tr_handshakeStealIO( handshake ); /* this steals its refcount too, which is
|
peer->io = tr_handshakeStealIO( handshake ); /* this steals its refcount too, which is
|
||||||
balanced by our unref in peerDestructor() */
|
balanced by our unref in peerDestructor() */
|
||||||
@@ -1478,7 +1484,7 @@ tr_peerMgrSetBlame( tr_torrent * tor,
|
|||||||
if( tr_bitfieldHas( peer->blame, pieceIndex ) )
|
if( tr_bitfieldHas( peer->blame, pieceIndex ) )
|
||||||
{
|
{
|
||||||
tordbg( t, "peer %s contributed to corrupt piece (%d); now has %d strikes",
|
tordbg( t, "peer %s contributed to corrupt piece (%d); now has %d strikes",
|
||||||
tr_atomAddrStr( peer->atom ),
|
tr_peerIoAddrStr( &peer->addr, peer->port ),
|
||||||
pieceIndex, (int)peer->strikes + 1 );
|
pieceIndex, (int)peer->strikes + 1 );
|
||||||
addStrike( t, peer );
|
addStrike( t, peer );
|
||||||
}
|
}
|
||||||
@@ -1876,10 +1882,10 @@ tr_peerMgrPeerStats( const tr_torrent * tor,
|
|||||||
const struct peer_atom * atom = peer->atom;
|
const struct peer_atom * atom = peer->atom;
|
||||||
tr_peer_stat * stat = ret + i;
|
tr_peer_stat * stat = ret + i;
|
||||||
|
|
||||||
tr_ntop( &atom->addr, stat->addr, sizeof( stat->addr ) );
|
tr_ntop( &peer->addr, stat->addr, sizeof( stat->addr ) );
|
||||||
tr_strlcpy( stat->client, ( peer->client ? peer->client : "" ),
|
tr_strlcpy( stat->client, ( peer->client ? peer->client : "" ),
|
||||||
sizeof( stat->client ) );
|
sizeof( stat->client ) );
|
||||||
stat->port = ntohs( atom->port );
|
stat->port = ntohs( peer->port );
|
||||||
stat->from = atom->from;
|
stat->from = atom->from;
|
||||||
stat->progress = peer->progress;
|
stat->progress = peer->progress;
|
||||||
stat->isEncrypted = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
|
stat->isEncrypted = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
|
||||||
@@ -2386,14 +2392,15 @@ reconnectTorrent( Torrent * t )
|
|||||||
struct peer_atom * atom = candidates[i];
|
struct peer_atom * atom = candidates[i];
|
||||||
tr_peerIo * io;
|
tr_peerIo * io;
|
||||||
|
|
||||||
tordbg( t, "Starting an OUTGOING connection with %s", tr_atomAddrStr( atom ) );
|
tordbg( t, "Starting an OUTGOING connection with %s",
|
||||||
|
tr_peerIoAddrStr( &atom->addr, atom->port ) );
|
||||||
|
|
||||||
io = tr_peerIoNewOutgoing( mgr->session, mgr->session->bandwidth, &atom->addr, atom->port, t->tor->info.hash );
|
io = tr_peerIoNewOutgoing( mgr->session, mgr->session->bandwidth, &atom->addr, atom->port, t->tor->info.hash );
|
||||||
|
|
||||||
if( io == NULL )
|
if( io == NULL )
|
||||||
{
|
{
|
||||||
tordbg( t, "peerIo not created; marking peer %s as unreachable",
|
tordbg( t, "peerIo not created; marking peer %s as unreachable",
|
||||||
tr_atomAddrStr( atom ) );
|
tr_peerIoAddrStr( &atom->addr, atom->port ) );
|
||||||
atom->myflags |= MYFLAG_UNREACHABLE;
|
atom->myflags |= MYFLAG_UNREACHABLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2636,39 +2643,3 @@ bandwidthPulse( void * vmgr )
|
|||||||
managerUnlock( mgr );
|
managerUnlock( mgr );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
|
||||||
****
|
|
||||||
***/
|
|
||||||
|
|
||||||
tr_port
|
|
||||||
tr_atomGetPort( const struct peer_atom * atom )
|
|
||||||
{
|
|
||||||
assert( tr_isAtom( atom ) );
|
|
||||||
|
|
||||||
return atom->port;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
tr_atomSetPort( struct peer_atom * atom, tr_port port )
|
|
||||||
{
|
|
||||||
assert( tr_isAtom( atom ) );
|
|
||||||
|
|
||||||
atom->port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
tr_atomAddrStr( const struct peer_atom * atom )
|
|
||||||
{
|
|
||||||
assert( tr_isAtom( atom ) );
|
|
||||||
|
|
||||||
return tr_peerIoAddrStr( &atom->addr, atom->port );
|
|
||||||
}
|
|
||||||
|
|
||||||
const tr_address *
|
|
||||||
tr_atomGetAddr( const struct peer_atom * atom )
|
|
||||||
{
|
|
||||||
assert( tr_isAtom( atom ) );
|
|
||||||
|
|
||||||
return &atom->addr;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -59,25 +59,6 @@ struct tr_bandwidth;
|
|||||||
struct tr_peerIo;
|
struct tr_peerIo;
|
||||||
struct tr_peermsgs;
|
struct tr_peermsgs;
|
||||||
|
|
||||||
/**
|
|
||||||
***
|
|
||||||
**/
|
|
||||||
|
|
||||||
/* opaque forward declaration */
|
|
||||||
struct peer_atom;
|
|
||||||
|
|
||||||
const tr_address* tr_atomGetAddr( const struct peer_atom * );
|
|
||||||
|
|
||||||
tr_port tr_atomGetPort( const struct peer_atom * atom );
|
|
||||||
|
|
||||||
void tr_atomSetPort( struct peer_atom * atom, tr_port port );
|
|
||||||
|
|
||||||
const char* tr_atomAddrStr( const struct peer_atom * );
|
|
||||||
|
|
||||||
/**
|
|
||||||
***
|
|
||||||
**/
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ENCRYPTION_PREFERENCE_UNKNOWN,
|
ENCRYPTION_PREFERENCE_UNKNOWN,
|
||||||
@@ -85,6 +66,9 @@ enum
|
|||||||
ENCRYPTION_PREFERENCE_NO
|
ENCRYPTION_PREFERENCE_NO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* opaque forward declaration */
|
||||||
|
struct peer_atom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State information about a connected peer.
|
* State information about a connected peer.
|
||||||
*
|
*
|
||||||
@@ -103,7 +87,9 @@ typedef struct tr_peer
|
|||||||
uint8_t strikes;
|
uint8_t strikes;
|
||||||
|
|
||||||
uint8_t encryption_preference;
|
uint8_t encryption_preference;
|
||||||
|
tr_port port;
|
||||||
tr_port dht_port;
|
tr_port dht_port;
|
||||||
|
tr_address addr;
|
||||||
struct tr_peerIo * io;
|
struct tr_peerIo * io;
|
||||||
struct peer_atom * atom;
|
struct peer_atom * atom;
|
||||||
|
|
||||||
@@ -123,9 +109,6 @@ typedef struct tr_peer
|
|||||||
}
|
}
|
||||||
tr_peer;
|
tr_peer;
|
||||||
|
|
||||||
/**
|
|
||||||
***
|
|
||||||
**/
|
|
||||||
|
|
||||||
int tr_pexCompare( const void * a, const void * b );
|
int tr_pexCompare( const void * a, const void * b );
|
||||||
|
|
||||||
|
|||||||
@@ -1059,8 +1059,8 @@ parseLtepHandshake( tr_peermsgs * msgs,
|
|||||||
|
|
||||||
/* get peer's listening port */
|
/* get peer's listening port */
|
||||||
if( tr_bencDictFindInt( &val, "p", &i ) ) {
|
if( tr_bencDictFindInt( &val, "p", &i ) ) {
|
||||||
tr_atomSetPort( msgs->peer->atom, htons( (uint16_t)i ) );
|
msgs->peer->port = htons( (uint16_t)i );
|
||||||
dbgmsg( msgs, "msgs->port is now %hu", tr_atomGetPort( msgs->peer->atom ) );
|
dbgmsg( msgs, "msgs->port is now %hu", msgs->peer->port );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get peer's maximum request queue size */
|
/* get peer's maximum request queue size */
|
||||||
@@ -1455,7 +1455,7 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen )
|
|||||||
dbgmsg( msgs, "Got a BT_PORT" );
|
dbgmsg( msgs, "Got a BT_PORT" );
|
||||||
tr_peerIoReadUint16( msgs->peer->io, inbuf, &msgs->peer->dht_port );
|
tr_peerIoReadUint16( msgs->peer->io, inbuf, &msgs->peer->dht_port );
|
||||||
if( msgs->peer->dht_port > 0 )
|
if( msgs->peer->dht_port > 0 )
|
||||||
tr_dhtAddNode( getSession(msgs), tr_atomGetAddr( msgs->peer->atom ), msgs->peer->dht_port, 0 );
|
tr_dhtAddNode( getSession(msgs), &msgs->peer->addr, msgs->peer->dht_port, 0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BT_FEXT_SUGGEST:
|
case BT_FEXT_SUGGEST:
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ THE SOFTWARE.
|
|||||||
int tr_dhtStatus( tr_session * session UNUSED,
|
int tr_dhtStatus( tr_session * session UNUSED,
|
||||||
int * setmeCount UNUSED ) { return TR_DHT_STOPPED; }
|
int * setmeCount UNUSED ) { return TR_DHT_STOPPED; }
|
||||||
int tr_dhtAddNode( tr_session * session UNUSED,
|
int tr_dhtAddNode( tr_session * session UNUSED,
|
||||||
const tr_address * addr UNUSED,
|
tr_address * addr UNUSED,
|
||||||
tr_port port UNUSED,
|
tr_port port UNUSED,
|
||||||
tr_bool bootstrap UNUSED ) { return 0; }
|
tr_bool bootstrap UNUSED ) { return 0; }
|
||||||
int tr_dhtAnnounce( tr_torrent * session UNUSED,
|
int tr_dhtAnnounce( tr_torrent * session UNUSED,
|
||||||
@@ -319,9 +319,7 @@ tr_dhtPort( const tr_session *ss )
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tr_dhtAddNode(tr_session * ss,
|
tr_dhtAddNode(tr_session *ss, tr_address *address, tr_port port,
|
||||||
const tr_address * address,
|
|
||||||
tr_port port,
|
|
||||||
tr_bool bootstrap)
|
tr_bool bootstrap)
|
||||||
{
|
{
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ tr_bool tr_dhtEnabled( const tr_session * );
|
|||||||
tr_port tr_dhtPort ( const tr_session * );
|
tr_port tr_dhtPort ( const tr_session * );
|
||||||
int tr_dhtStatus( tr_session *, int * setme_nodeCount );
|
int tr_dhtStatus( tr_session *, int * setme_nodeCount );
|
||||||
const char *tr_dhtPrintableStatus(int status);
|
const char *tr_dhtPrintableStatus(int status);
|
||||||
int tr_dhtAddNode( tr_session *, const tr_address *, tr_port, tr_bool bootstrap );
|
int tr_dhtAddNode( tr_session *, tr_address *, tr_port, tr_bool bootstrap );
|
||||||
int tr_dhtAnnounce( tr_torrent *, tr_bool announce );
|
int tr_dhtAnnounce( tr_torrent *, tr_bool announce );
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
#ifndef TR_HTTP_H
|
#ifndef TR_HTTP_H
|
||||||
#define TR_HTTP_H
|
#define TR_HTTP_H
|
||||||
|
|
||||||
struct tr_address;
|
|
||||||
|
|
||||||
typedef struct tr_web tr_web;
|
typedef struct tr_web tr_web;
|
||||||
|
|
||||||
tr_web* tr_webInit( tr_session * session,
|
tr_web* tr_webInit( tr_session * session,
|
||||||
|
|||||||
Reference in New Issue
Block a user