From 417f3fd3b082ad2bfd0b59f05e56c234d504ea16 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 28 Oct 2010 23:19:53 +0000 Subject: [PATCH] (trunk libT) #3681 "tr-lpd.c's lpd_configureSocket() function is redundant" -- fixed. --- libtransmission/tr-lpd.c | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/libtransmission/tr-lpd.c b/libtransmission/tr-lpd.c index 34a7f4bf5..9734616da 100644 --- a/libtransmission/tr-lpd.c +++ b/libtransmission/tr-lpd.c @@ -28,7 +28,6 @@ THE SOFTWARE. #include /* sig_atomic_t */ #include #include /* close() */ -#include /* fcntl(), O_NONBLOCK */ #include /* toupper() */ #ifdef WIN32 #include @@ -36,8 +35,6 @@ THE SOFTWARE. #include #include typedef uint16_t in_port_t; /* all missing */ - extern int fcntl (int fd, int cmd, ...); - #define O_NONBLOCK 04000 #else #include #include /* socket(), bind() */ @@ -46,6 +43,7 @@ THE SOFTWARE. /* third party */ #include +#include /* libT */ #include "transmission.h" @@ -251,33 +249,6 @@ static int lpd_extractParam( const char* const str, const char* const name, int /** * @} */ - -/** -* @brief Configures additional capabilities for a socket */ -static int -lpd_configureSocket( int sock, int add ) -{ -#ifdef WIN32 - unsigned long flags = 1; - - if (add != O_NONBLOCK) - return -1; /* not supported */ - if (ioctlsocket(sock, FIONBIO, &flags) == SOCKET_ERROR) - return -1; -#else - /* read-modify-write socket flags */ - int flags = fcntl( sock, F_GETFL ); - - if( flags < 0 ) - return -1; - - if( fcntl( sock, F_SETFL, add | flags ) == -1 ) - return -1; -#endif - - return add; -} - /** * @brief Initializes Local Peer Discovery for this node * @@ -310,8 +281,7 @@ int tr_lpdInit( tr_session* ss, tr_address* tr_addr UNUSED ) if( lpd_socket < 0 ) goto fail; - /* enable non-blocking operation */ - if( lpd_configureSocket( lpd_socket, O_NONBLOCK ) < 0 ) + if( evutil_make_socket_nonblocking( lpd_socket ) < 0 ) goto fail; if( setsockopt( lpd_socket, SOL_SOCKET, SO_REUSEADDR, @@ -350,8 +320,7 @@ int tr_lpdInit( tr_session* ss, tr_address* tr_addr UNUSED ) if( lpd_socket2 < 0 ) goto fail; - /* enable non-blocking operation */ - if( lpd_configureSocket( lpd_socket2, O_NONBLOCK ) < 0 ) + if( evutil_make_socket_nonblocking( lpd_socket2 ) < 0 ) goto fail; /* configure outbound multicast TTL */ -- 2.40.0