more tweaks
This commit is contained in:
parent
c9359d8bde
commit
fa200efd09
|
@ -847,19 +847,17 @@ msgsCallbackFunc( void * vpeer, void * vevent, void * vt )
|
||||||
static void
|
static void
|
||||||
ensureAtomExists( Torrent * t, const struct in_addr * addr, uint16_t port, uint8_t flags, uint8_t from )
|
ensureAtomExists( Torrent * t, const struct in_addr * addr, uint16_t port, uint8_t flags, uint8_t from )
|
||||||
{
|
{
|
||||||
struct peer_atom * a = getExistingAtom( t, addr );
|
if( getExistingAtom( t, addr ) == NULL )
|
||||||
|
|
||||||
if( a == NULL )
|
|
||||||
{
|
{
|
||||||
|
struct peer_atom * a;
|
||||||
a = tr_new0( struct peer_atom, 1 );
|
a = tr_new0( struct peer_atom, 1 );
|
||||||
a->addr = *addr;
|
a->addr = *addr;
|
||||||
a->port = port;
|
a->port = port;
|
||||||
a->flags = flags;
|
a->flags = flags;
|
||||||
|
a->from = from;
|
||||||
tordbg( t, "got a new atom: %s", tr_peerIoAddrStr(&a->addr,a->port) );
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
a->from = from;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: this is kind of a mess. */
|
/* FIXME: this is kind of a mess. */
|
||||||
|
@ -872,7 +870,7 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
||||||
{
|
{
|
||||||
int ok = isConnected;
|
int ok = isConnected;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
const struct in_addr * in_addr;
|
const struct in_addr * addr;
|
||||||
tr_peerMgr * manager = (tr_peerMgr*) vmanager;
|
tr_peerMgr * manager = (tr_peerMgr*) vmanager;
|
||||||
Torrent * t;
|
Torrent * t;
|
||||||
tr_handshake * ours;
|
tr_handshake * ours;
|
||||||
|
@ -899,19 +897,14 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
||||||
if( t != NULL )
|
if( t != NULL )
|
||||||
torrentLock( t );
|
torrentLock( t );
|
||||||
|
|
||||||
in_addr = tr_peerIoGetAddress( io, &port );
|
addr = tr_peerIoGetAddress( io, &port );
|
||||||
|
|
||||||
if( !ok || !t || !t->isRunning )
|
if( !ok || !t || !t->isRunning )
|
||||||
{
|
{
|
||||||
tr_peerIoFree( io );
|
tr_peerIoFree( io );
|
||||||
|
|
||||||
if( t )
|
|
||||||
++getExistingAtom( t, in_addr )->numFails;
|
|
||||||
}
|
}
|
||||||
else /* looking good */
|
else /* looking good */
|
||||||
{
|
{
|
||||||
uint16_t port;
|
|
||||||
const struct in_addr * addr = tr_peerIoGetAddress( io, &port );
|
|
||||||
struct peer_atom * atom;
|
struct peer_atom * atom;
|
||||||
ensureAtomExists( t, addr, port, 0, TR_PEER_FROM_INCOMING );
|
ensureAtomExists( t, addr, port, 0, TR_PEER_FROM_INCOMING );
|
||||||
atom = getExistingAtom( t, addr );
|
atom = getExistingAtom( t, addr );
|
||||||
|
|
Loading…
Reference in New Issue