(trunk libT) add a wrapper function, tr_netCloseSocket(), around EVUTIL_CLOSESOCKET() so that not all of our code has to #include evutil

This commit is contained in:
Charles Kerr 2009-10-27 20:27:27 +00:00
parent 7a4f22ba12
commit 858e691381
6 changed files with 18 additions and 9 deletions

View File

@ -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;
}

View File

@ -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 )
{

View File

@ -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_ */

View File

@ -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 );
}
}

View File

@ -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");

View File

@ -19,6 +19,7 @@
#include <signal.h>
#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] );
}
/**