Ignore:
Timestamp:
Oct 28, 2010, 11:19:53 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3681 "tr-lpd.c's lpd_configureSocket() function is redundant" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tr-lpd.c

    r11299 r11357  
    2929#include <sys/time.h>
    3030#include <unistd.h> /* close() */
    31 #include <fcntl.h> /* fcntl(), O_NONBLOCK */
    3231#include <ctype.h> /* toupper() */
    3332#ifdef WIN32
     
    3736  #include <ws2tcpip.h>
    3837  typedef uint16_t in_port_t;                   /* all missing */
    39   extern int fcntl (int fd, int cmd, ...);
    40   #define O_NONBLOCK    04000
    4138#else
    4239  #include <sys/types.h>
     
    4744/* third party */
    4845#include <event.h>
     46#include <evutil.h>
    4947
    5048/* libT */
     
    252250* @} */
    253251
    254 
    255 /**
    256 * @brief Configures additional capabilities for a socket */
    257 static int
    258 lpd_configureSocket( int sock, int add )
    259 {
    260 #ifdef WIN32
    261     unsigned long flags = 1;
    262 
    263     if (add != O_NONBLOCK)
    264         return -1;              /* not supported */
    265     if (ioctlsocket(sock, FIONBIO, &flags) == SOCKET_ERROR)
    266         return -1;
    267 #else
    268     /* read-modify-write socket flags */
    269     int flags = fcntl( sock, F_GETFL );
    270 
    271     if( flags < 0 )
    272         return -1;
    273 
    274     if( fcntl( sock, F_SETFL, add | flags ) == -1 )
    275         return -1;
    276 #endif
    277 
    278     return add;
    279 }
    280 
    281252/**
    282253* @brief Initializes Local Peer Discovery for this node
     
    311282            goto fail;
    312283
    313         /* enable non-blocking operation */
    314         if( lpd_configureSocket( lpd_socket, O_NONBLOCK ) < 0 )
     284        if( evutil_make_socket_nonblocking( lpd_socket ) < 0 )
    315285            goto fail;
    316286
     
    351321            goto fail;
    352322
    353         /* enable non-blocking operation */
    354         if( lpd_configureSocket( lpd_socket2, O_NONBLOCK ) < 0 )
     323        if( evutil_make_socket_nonblocking( lpd_socket2 ) < 0 )
    355324            goto fail;
    356325
Note: See TracChangeset for help on using the changeset viewer.