Changeset 426
- Timestamp:
- 10/07/06 16:17:50 (2 years ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/admin_server.c (modified) (1 diff)
- cherokee/trunk/cherokee/socket.c (modified) (7 diffs)
- cherokee/trunk/cherokee/thread.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r424 r426 1 2006-10-07 A.D.F <adefacc@tin.it> 2 3 * cherokee/thread.c, cherokee/socket.c, cherokee/socket.h: Better 4 fd management. Fixes a few problems with fd leaks. 5 1 6 2006-10-03 A.D.F <adefacc@tin.it> 2 7 cherokee/trunk/cherokee/admin_server.c
r384 r426 24 24 25 25 #include "admin_server.h" 26 #include "util.h"27 26 #include "server-protected.h" 28 27 #include "connection-protected.h" 29 28 #include "connection_info.h" 29 #include "util.h" 30 30 31 31 32 /* Server Port cherokee/trunk/cherokee/socket.c
r392 r426 445 445 cherokee_socket_close (cherokee_socket_t *socket) 446 446 { 447 int re;448 449 447 if (socket->socket < 0) { 450 448 return ret_error; … … 482 480 cherokee_socket_shutdown (cherokee_socket_t *socket, int how) 483 481 { 484 int re;485 486 482 /* If the read side of the socket has been closed but the 487 483 * write side is not, then don't bother to call shutdown … … 494 490 return ret_error; 495 491 496 re = shutdown (socket->socket, how); 497 498 return (re == 0) ? ret_ok : ret_error; 492 if (unlikely (shutdown (socket->socket, how) != 0)) 493 return ret_error; 494 495 return ret_ok; 499 496 } 500 497 … … 580 577 581 578 ret = cherokee_socket_set_sockaddr (socket, fd, &sa); 582 if (unlikely(ret < ret_ok)) return ret; 579 if (unlikely(ret < ret_ok)) { 580 cherokee_close_fd (socket); 581 return ret; 582 } 583 583 584 584 return ret_ok; … … 605 605 606 606 memcpy (&socket->client_addr, sa, socket->client_addr_len); 607 608 /* Status is no more closed. 609 */ 610 socket->status = socket_reading; 607 611 608 612 SOCKET_FD(socket) = fd; … … 624 628 return ret_error; 625 629 } 626 627 /* Close-on-exec628 */629 CLOSE_ON_EXEC (new_socket);630 630 631 631 /* Disable Nagle's algorithm for this connection. … … 635 635 setsockopt (new_socket, IPPROTO_TCP, TCP_NODELAY, (const void *)&tmp, sizeof(tmp)); 636 636 637 /* Close-on-exec 638 */ 639 CLOSE_ON_EXEC (new_socket); 640 637 641 /* Enables nonblocking I/O. 638 642 */ cherokee/trunk/cherokee/thread.c
r389 r426 1306 1306 1307 1307 /* We got the new socket, now set it up in a new connection object 1308 */1308 */ 1309 1309 ret = cherokee_thread_get_new_connection (thd, &new_conn); 1310 1310 if (unlikely(ret < ret_ok)) { 1311 1311 PRINT_ERROR_S ("ERROR: Trying to get a new connection object\n"); 1312 cherokee_close_fd (new_fd); 1312 1313 return 0; 1313 1314 } 1314 1315 1315 1316 ret = cherokee_socket_set_sockaddr (&new_conn->socket, new_fd, &new_sa); 1316 if (unlikely(ret < ret_ok)) goto error; 1317 if (unlikely(ret < ret_ok)) { 1318 PRINT_ERROR_S ("ERROR: Trying to set sockaddr\n"); 1319 cherokee_close_fd (new_fd); 1320 goto error; 1321 } 1317 1322 1318 1323 /* May active the TLS support cherokee/trunk/cherokee/util.c
r405 r426 1248 1248 return ret_no_sys; 1249 1249 } 1250 1251 1252 ret_t 1253 cherokee_close_fd (cint_t fd) 1254 { 1255 int re; 1256 1257 if (fd < 0) { 1258 return ret_error; 1259 } 1260 1261 #ifdef _WIN32 1262 re = closesocket (fd); 1263 #else 1264 re = close (fd); 1265 #endif 1266 1267 TRACE (ENTRIES",close_fd", "fd=%d re=%d\n", fd, re); 1268 1269 return (re == 0) ? ret_ok : ret_error; 1270 } cherokee/trunk/cherokee/util.h
r399 r426 103 103 ret_t cherokee_sys_fdlimit_get (cuint_t *limit); 104 104 ret_t cherokee_sys_fdlimit_set (cuint_t limit); 105 ret_t cherokee_close_fd (cint_t fd); 105 106 void cherokee_trace (const char *entry, const char *file, int line, const char *func, const char *fmt, ...); 106 107