Changeset 5123
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/ipc.c
r5122 r5123 27 27 #include <sys/un.h> 28 28 #include <errno.h> 29 #include <fcntl.h>30 29 #include <stdio.h> 31 30 #include <stdlib.h> … … 35 34 #include <gtk/gtk.h> 36 35 #include <glib/gi18n.h> 36 37 #include <libevent/evutil.h> 37 38 38 39 #include <libtransmission/transmission.h> … … 310 311 g_strerror(errno)); 311 312 if(0 <= con->fd) 312 close(con->fd);313 EVUTIL_CLOSESOCKET(con->fd); 313 314 con->fd = -1; 314 315 rmsock(); … … 347 348 if( NULL == con->source ) 348 349 { 349 close( con->fd );350 EVUTIL_CLOSESOCKET( con->fd ); 350 351 return FALSE; 351 352 } … … 354 355 if( NULL == buf ) 355 356 { 356 close( con->fd );357 EVUTIL_CLOSESOCKET( con->fd ); 357 358 return FALSE; 358 359 } … … 379 380 { 380 381 g_free( newcon ); 381 close( fd );382 EVUTIL_CLOSESOCKET( fd ); 382 383 return; 383 384 } … … 388 389 ipc_freecon( newcon->ipc ); 389 390 g_free( newcon ); 390 close( fd );391 EVUTIL_CLOSESOCKET( fd ); 391 392 return; 392 393 } … … 397 398 ipc_freecon( newcon->ipc ); 398 399 g_free( newcon ); 399 close( fd );400 EVUTIL_CLOSESOCKET( fd ); 400 401 return; 401 402 } … … 542 543 543 544 if(0 <= con->fd) 544 close(con->fd);545 EVUTIL_CLOSESOCKET(con->fd); 545 546 con->fd = -1; 546 547 ipc_freecon( con->ipc ); -
trunk/gtk/tr-io.c
r5119 r5123 25 25 #include <sys/types.h> 26 26 #include <sys/socket.h> 27 #include <sys/uio.h>28 27 #include <errno.h> 29 #include <fcntl.h> 30 #include <string.h> 31 #include <unistd.h> 28 #include <string.h> /* memset, memmove */ 29 #include <unistd.h> /* read, write */ 32 30 33 31 #include <glib.h> 32 33 #include <libevent/evutil.h> /* evutil_make_socket_nonblocking */ 34 34 35 35 #include "tr-io.h" 36 36 #include "util.h" 37 37 38 #define IO_BLOCKSIZE 38 #define IO_BLOCKSIZE (1024) 39 39 40 40 struct iosource { … … 61 61 }; 62 62 63 static gboolean64 nonblock(int fd);65 63 static struct iosource * 66 64 newsource(void); … … 93 91 }; 94 92 93 static int 94 nonblock(int fd) 95 { 96 const int err = evutil_make_socket_nonblocking( fd ); 97 return err; 98 } 99 95 100 GSource * 96 101 io_new(int fd, ioidfunc_t sent, iodatafunc_t received, … … 98 103 struct iosource *io; 99 104 100 if( !nonblock(fd))105 if( nonblock( fd ) ) 101 106 return NULL; 102 107 … … 126 131 g_assert(NULL != accepted); 127 132 128 if( !nonblock(fd))133 if( nonblock( fd ) ) 129 134 return NULL; 130 135 … … 143 148 144 149 return (GSource*)io; 145 }146 147 static gboolean148 nonblock(int fd) {149 int flags;150 151 if(0 > (flags = fcntl(fd, F_GETFL)) ||152 0 > fcntl(fd, F_SETFL, flags | O_NONBLOCK))153 return FALSE;154 155 return TRUE;156 150 } 157 151
Note: See TracChangeset
for help on using the changeset viewer.