Changeset 706

Show
Ignore:
Timestamp:
04/18/07 08:31:53 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r705 r706  
     12007-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         
    1152007-04-14  A.D.F  <adefacc@tin.it> 
    216 
  • cherokee/trunk/cherokee/server.c

    r702 r706  
    734734        ret_t ret; 
    735735        int   i, fds_per_thread, max_fds; 
     736#ifdef HAVE_PTHREAD 
     737        int   thr_fds, spare_fds; 
     738#endif 
    736739 
    737740        /* Leave some spare fds. 
     
    741744                return ret_error; 
    742745        } 
    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; 
    744753 
    745754        /* Set fd upper limit for threads. 
     
    750759                srv->thread_num = max_fds; 
    751760        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 
    752765 
    753766        /* Create the main thread 
     
    776789        for (i = 0; i < srv->thread_num - 1; i++) { 
    777790                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                } 
    778802 
    779803                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); 
    781805                if (unlikely(ret < ret_ok)) return ret; 
    782806                 
  • cherokee/trunk/cherokee/socket.c

    r699 r706  
    441441 
    442442#ifdef HAVE_TLS 
    443         if (socket->is_tls == TLS) { 
    444  
     443        if (socket->is_tls == TLS && socket->session != NULL) { 
    445444#if   defined (HAVE_GNUTLS) 
    446445 
  • cherokee/trunk/cherokee/thread.c

    r705 r706  
    13581358         */ 
    13591359        ret = cherokee_thread_add_connection (thd, new_conn); 
     1360 
     1361        /* Release the thread ownership 
     1362         */ 
     1363        CHEROKEE_MUTEX_UNLOCK (&thd->ownership); 
     1364 
    13601365        if (unlikely (ret < ret_ok)) { 
     1366                cherokee_close_fd (new_fd); 
    13611367                goto error; 
    13621368        } 
    1363  
    1364         /* Release the thread ownership 
    1365          */ 
    1366         CHEROKEE_MUTEX_UNLOCK (&thd->ownership); 
    13671369 
    13681370        TRACE (ENTRIES, "new conn %p, fd %d\n", new_conn, new_fd); 
     
    13731375        TRACE (ENTRIES, "error accepting connection! fd %d\n", srv_socket); 
    13741376 
     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; 
    13751381        connection_reuse_or_free (thd, new_conn); 
    13761382        return 0;