mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
(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:
parent
7a4f22ba12
commit
858e691381
6 changed files with 18 additions and 9 deletions
|
@ -629,7 +629,7 @@ tr_fdSocketAccept( tr_session * session,
|
||||||
|
|
||||||
if( ( s >= 0 ) && gFd->socketCount > gFd->socketLimit )
|
if( ( s >= 0 ) && gFd->socketCount > gFd->socketLimit )
|
||||||
{
|
{
|
||||||
EVUTIL_CLOSESOCKET( s );
|
tr_netCloseSocket( s );
|
||||||
s = -1;
|
s = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ tr_fdSocketClose( tr_session * session, int fd )
|
||||||
|
|
||||||
if( fd >= 0 )
|
if( fd >= 0 )
|
||||||
{
|
{
|
||||||
EVUTIL_CLOSESOCKET( fd );
|
tr_netCloseSocket( fd );
|
||||||
--gFd->socketCount;
|
--gFd->socketCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs,
|
||||||
|
|
||||||
if( evutil_make_socket_nonblocking( fd ) < 0 ) {
|
if( evutil_make_socket_nonblocking( fd ) < 0 ) {
|
||||||
*errOut = sockerrno;
|
*errOut = sockerrno;
|
||||||
EVUTIL_CLOSESOCKET( fd );
|
tr_netCloseSocket( fd );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs,
|
||||||
if( !suppressMsgs )
|
if( !suppressMsgs )
|
||||||
tr_err( _( "Couldn't bind port %d on %s: %s" ),
|
tr_err( _( "Couldn't bind port %d on %s: %s" ),
|
||||||
port, tr_ntop_non_ts( addr ), tr_strerror( err ) );
|
port, tr_ntop_non_ts( addr ), tr_strerror( err ) );
|
||||||
EVUTIL_CLOSESOCKET( fd );
|
tr_netCloseSocket( fd );
|
||||||
*errOut = err;
|
*errOut = err;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs,
|
||||||
|
|
||||||
if( listen( fd, 128 ) == -1 ) {
|
if( listen( fd, 128 ) == -1 ) {
|
||||||
*errOut = sockerrno;
|
*errOut = sockerrno;
|
||||||
EVUTIL_CLOSESOCKET( fd );
|
tr_netCloseSocket( fd );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ tr_net_hasIPv6( tr_port port )
|
||||||
if( fd >= 0 || err != EAFNOSUPPORT ) /* we support ipv6 */
|
if( fd >= 0 || err != EAFNOSUPPORT ) /* we support ipv6 */
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
if( fd >= 0 )
|
if( fd >= 0 )
|
||||||
EVUTIL_CLOSESOCKET( fd );
|
tr_netCloseSocket( fd );
|
||||||
alreadyDone = TRUE;
|
alreadyDone = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,6 +451,12 @@ tr_netAccept( tr_session * session,
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tr_netCloseSocket( int fd )
|
||||||
|
{
|
||||||
|
EVUTIL_CLOSESOCKET( fd );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tr_netClose( tr_session * session, int s )
|
tr_netClose( tr_session * session, int s )
|
||||||
{
|
{
|
||||||
|
|
|
@ -116,6 +116,8 @@ int tr_netSetTOS( int s,
|
||||||
|
|
||||||
void tr_netClose( tr_session * session, int s );
|
void tr_netClose( tr_session * session, int s );
|
||||||
|
|
||||||
|
void tr_netCloseSocket( int fd );
|
||||||
|
|
||||||
void tr_netInit( void );
|
void tr_netInit( void );
|
||||||
|
|
||||||
#endif /* _TR_NET_H_ */
|
#endif /* _TR_NET_H_ */
|
||||||
|
|
|
@ -147,7 +147,7 @@ close_bindinfo( struct tr_bindinfo * b )
|
||||||
if( ( b != NULL ) && ( b->socket >=0 ) )
|
if( ( b != NULL ) && ( b->socket >=0 ) )
|
||||||
{
|
{
|
||||||
event_del( &b->ev );
|
event_del( &b->ev );
|
||||||
EVUTIL_CLOSESOCKET( b->socket );
|
tr_netCloseSocket( b->socket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ tr_dhtUninit(tr_session *ss)
|
||||||
}
|
}
|
||||||
|
|
||||||
dht_uninit( dht_socket, 0 );
|
dht_uninit( dht_socket, 0 );
|
||||||
EVUTIL_CLOSESOCKET( dht_socket );
|
tr_netCloseSocket( dht_socket );
|
||||||
|
|
||||||
tr_ndbg("DHT", "Done uninitialising DHT");
|
tr_ndbg("DHT", "Done uninitialising DHT");
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "transmission.h"
|
#include "transmission.h"
|
||||||
|
#include "net.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -271,7 +272,7 @@ tr_eventClose( tr_session * session )
|
||||||
|
|
||||||
session->events->die = TRUE;
|
session->events->die = TRUE;
|
||||||
tr_deepLog( __FILE__, __LINE__, NULL, "closing trevent pipe" );
|
tr_deepLog( __FILE__, __LINE__, NULL, "closing trevent pipe" );
|
||||||
EVUTIL_CLOSESOCKET( session->events->fds[1] );
|
tr_netCloseSocket( session->events->fds[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue