diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index 34de1576f..dc4310261 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -629,7 +629,7 @@ tr_fdSocketAccept( tr_session * session, if( ( s >= 0 ) && gFd->socketCount > gFd->socketLimit ) { - EVUTIL_CLOSESOCKET( s ); + tr_netCloseSocket( s ); s = -1; } @@ -675,7 +675,7 @@ tr_fdSocketClose( tr_session * session, int fd ) if( fd >= 0 ) { - EVUTIL_CLOSESOCKET( fd ); + tr_netCloseSocket( fd ); --gFd->socketCount; } diff --git a/libtransmission/net.c b/libtransmission/net.c index 15d81926b..9707c29e5 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -368,7 +368,7 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs, if( evutil_make_socket_nonblocking( fd ) < 0 ) { *errOut = sockerrno; - EVUTIL_CLOSESOCKET( fd ); + tr_netCloseSocket( fd ); return -1; } @@ -391,7 +391,7 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs, if( !suppressMsgs ) tr_err( _( "Couldn't bind port %d on %s: %s" ), port, tr_ntop_non_ts( addr ), tr_strerror( err ) ); - EVUTIL_CLOSESOCKET( fd ); + tr_netCloseSocket( fd ); *errOut = err; return -1; } @@ -401,7 +401,7 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs, if( listen( fd, 128 ) == -1 ) { *errOut = sockerrno; - EVUTIL_CLOSESOCKET( fd ); + tr_netCloseSocket( fd ); return -1; } @@ -428,7 +428,7 @@ tr_net_hasIPv6( tr_port port ) if( fd >= 0 || err != EAFNOSUPPORT ) /* we support ipv6 */ result = TRUE; if( fd >= 0 ) - EVUTIL_CLOSESOCKET( fd ); + tr_netCloseSocket( fd ); alreadyDone = TRUE; } @@ -451,6 +451,12 @@ tr_netAccept( tr_session * session, return fd; } +void +tr_netCloseSocket( int fd ) +{ + EVUTIL_CLOSESOCKET( fd ); +} + void tr_netClose( tr_session * session, int s ) { diff --git a/libtransmission/net.h b/libtransmission/net.h index 9bb478f39..48a1bf325 100644 --- a/libtransmission/net.h +++ b/libtransmission/net.h @@ -116,6 +116,8 @@ int tr_netSetTOS( int s, void tr_netClose( tr_session * session, int s ); +void tr_netCloseSocket( int fd ); + void tr_netInit( void ); #endif /* _TR_NET_H_ */ diff --git a/libtransmission/session.c b/libtransmission/session.c index 516695a78..b6284e9f4 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -147,7 +147,7 @@ close_bindinfo( struct tr_bindinfo * b ) if( ( b != NULL ) && ( b->socket >=0 ) ) { event_del( &b->ev ); - EVUTIL_CLOSESOCKET( b->socket ); + tr_netCloseSocket( b->socket ); } } diff --git a/libtransmission/tr-dht.c b/libtransmission/tr-dht.c index 31492c7b3..247528d74 100644 --- a/libtransmission/tr-dht.c +++ b/libtransmission/tr-dht.c @@ -255,7 +255,7 @@ tr_dhtUninit(tr_session *ss) } dht_uninit( dht_socket, 0 ); - EVUTIL_CLOSESOCKET( dht_socket ); + tr_netCloseSocket( dht_socket ); tr_ndbg("DHT", "Done uninitialising DHT"); diff --git a/libtransmission/trevent.c b/libtransmission/trevent.c index e3fdefd93..8768dcd46 100644 --- a/libtransmission/trevent.c +++ b/libtransmission/trevent.c @@ -19,6 +19,7 @@ #include #include "transmission.h" +#include "net.h" #include "session.h" #ifdef WIN32 @@ -271,7 +272,7 @@ tr_eventClose( tr_session * session ) session->events->die = TRUE; tr_deepLog( __FILE__, __LINE__, NULL, "closing trevent pipe" ); - EVUTIL_CLOSESOCKET( session->events->fds[1] ); + tr_netCloseSocket( session->events->fds[1] ); } /**