Changeset 706
- Timestamp:
- 04/18/07 08:31:53 (2 years ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/server.c (modified) (4 diffs)
- cherokee/trunk/cherokee/socket.c (modified) (1 diff)
- cherokee/trunk/cherokee/thread.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r705 r706 1 2007-04-17 A.D.F <adefacc@tin.it> 2 3 * cherokee/socket.c: 4 - cleanup HTTPS session only if it is not NULL; 5 6 * cherokee/server.c: 7 - force good limits for max. number of fds; 8 9 * cherokee/thread.c: 10 - __accept_from_server(), 11 fix locking and always close new accepted fd 12 on error (fixes a socket leak which lead 13 to many idle connections left open). 14 1 15 2007-04-14 A.D.F <adefacc@tin.it> 2 16 cherokee/trunk/cherokee/server.c
r702 r706 734 734 ret_t ret; 735 735 int i, fds_per_thread, max_fds; 736 #ifdef HAVE_PTHREAD 737 int thr_fds, spare_fds; 738 #endif 736 739 737 740 /* Leave some spare fds. … … 741 744 return ret_error; 742 745 } 743 max_fds = srv->system_fd_limit - 5; 746 if (srv->system_fd_limit > 1024) 747 max_fds = srv->system_fd_limit - 20; 748 else 749 if (srv->system_fd_limit > 100) 750 max_fds = srv->system_fd_limit - 10; 751 else 752 max_fds = srv->system_fd_limit - 5; 744 753 745 754 /* Set fd upper limit for threads. … … 750 759 srv->thread_num = max_fds; 751 760 fds_per_thread = max_fds / srv->thread_num; 761 #ifdef HAVE_PTHREAD 762 thr_fds = fds_per_thread * srv->thread_num; 763 spare_fds = max_fds - thr_fds; 764 #endif 752 765 753 766 /* Create the main thread … … 776 789 for (i = 0; i < srv->thread_num - 1; i++) { 777 790 cherokee_thread_t *thread; 791 int fds_per_thread1 = fds_per_thread; 792 793 /* Add one more fd to this thread, 794 * this is useful if we are using a huge number of threads 795 * (i.e. 1000 or more) and we don't want to leave lots of 796 * unused fds. 797 */ 798 if (spare_fds > 0) { 799 spare_fds--; 800 fds_per_thread1++; 801 } 778 802 779 803 ret = cherokee_thread_new (&thread, srv, thread_async, 780 srv->fdpoll_method, srv->system_fd_limit, fds_per_thread);804 srv->fdpoll_method, srv->system_fd_limit, fds_per_thread1); 781 805 if (unlikely(ret < ret_ok)) return ret; 782 806 cherokee/trunk/cherokee/socket.c
r699 r706 441 441 442 442 #ifdef HAVE_TLS 443 if (socket->is_tls == TLS) { 444 443 if (socket->is_tls == TLS && socket->session != NULL) { 445 444 #if defined (HAVE_GNUTLS) 446 445 cherokee/trunk/cherokee/thread.c
r705 r706 1358 1358 */ 1359 1359 ret = cherokee_thread_add_connection (thd, new_conn); 1360 1361 /* Release the thread ownership 1362 */ 1363 CHEROKEE_MUTEX_UNLOCK (&thd->ownership); 1364 1360 1365 if (unlikely (ret < ret_ok)) { 1366 cherokee_close_fd (new_fd); 1361 1367 goto error; 1362 1368 } 1363 1364 /* Release the thread ownership1365 */1366 CHEROKEE_MUTEX_UNLOCK (&thd->ownership);1367 1369 1368 1370 TRACE (ENTRIES, "new conn %p, fd %d\n", new_conn, new_fd); … … 1373 1375 TRACE (ENTRIES, "error accepting connection! fd %d\n", srv_socket); 1374 1376 1377 /* New socket has alread been closed, 1378 * so here we reinit fd to default init value. 1379 */ 1380 SOCKET_FD(&new_conn->socket) = -1; 1375 1381 connection_reuse_or_free (thd, new_conn); 1376 1382 return 0;