diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index dbb020b13..50df5afe5 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -358,8 +358,14 @@ int tr_fdSocketAccept( int b, struct in_addr * addr, in_port_t * port ) if( s > -1 ) { SocketSetPriority( s, 0 ); - *addr = sock.sin_addr; - *port = sock.sin_port; + if( NULL != addr ) + { + *addr = sock.sin_addr; + } + if( NULL != port ) + { + *port = sock.sin_port; + } gFd->normal++; } tr_lockUnlock( &gFd->lock ); diff --git a/libtransmission/peer.c b/libtransmission/peer.c index 50d304846..dde73e049 100644 --- a/libtransmission/peer.c +++ b/libtransmission/peer.c @@ -41,7 +41,7 @@ struct tr_peer_s tr_torrent_t * tor; struct in_addr addr; - in_port_t port; + in_port_t port; /* peer's listening port, 0 if not known */ #define PEER_STATUS_IDLE 1 /* Need to connect */ #define PEER_STATUS_CONNECTING 2 /* Trying to send handshake */ @@ -617,8 +617,8 @@ int tr_peerGetConnectable( tr_torrent_t * tor, uint8_t ** _buf ) { peer = tor->peers[i]; - /* Skip peers that came from incoming connections */ - if( peer->incoming ) + /* Skip peers with no known listening port */ + if( 0 == peer->port ) continue; memcpy( &buf[count*6], &peer->addr, 4 ); diff --git a/libtransmission/shared.c b/libtransmission/shared.c index 454e7ecaf..ac101da3d 100644 --- a/libtransmission/shared.c +++ b/libtransmission/shared.c @@ -320,7 +320,6 @@ static void SetPublicPort( tr_shared_t * s, int port ) static void AcceptPeers( tr_shared_t * s ) { int socket; - in_port_t port; struct in_addr addr; for( ;; ) @@ -330,12 +329,12 @@ static void AcceptPeers( tr_shared_t * s ) break; } - socket = tr_netAccept( s->bindSocket, &addr, &port ); + socket = tr_netAccept( s->bindSocket, &addr, NULL ); if( socket < 0 ) { break; } - s->peers[s->peerCount++] = tr_peerInit( addr, port, socket ); + s->peers[s->peerCount++] = tr_peerInit( addr, 0, socket ); } }