Changeset 1814

Show
Ignore:
Timestamp:
08/14/08 13:50:04 (3 months ago)
Author:
alo
Message:

--

Files:

Legend:

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

    r1812 r1814  
    112008-08-14  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * cherokee/connection-protected.h, cherokee/thread.c, 
     4        cherokee/connection.c: Polish the Keep-Alive management. 
    25 
    36        * cherokee/server.c (add_vserver): Adds a sanity check. It makes 
  • cherokee/trunk/cherokee/connection-protected.h

    r1788 r1814  
    224224ret_t cherokee_connection_check_only_secure      (cherokee_connection_t *conn, cherokee_config_entry_t *config_entry); 
    225225ret_t cherokee_connection_check_http_method      (cherokee_connection_t *conn, cherokee_config_entry_t *config_entry); 
     226void  cherokee_connection_set_keepalive          (cherokee_connection_t *conn); 
    226227 
    227228/* Iteration 
  • cherokee/trunk/cherokee/connection.c

    r1806 r1814  
    17081708 
    17091709 
    1710 ret_t 
    1711 cherokee_connection_parse_header (cherokee_connection_t *conn, cherokee_encoder_table_t *encoders) 
    1712 
    1713         ret_t    ret; 
    1714         char    *ptr; 
    1715         cuint_t  ptr_len; 
    1716  
    1717         /* Look for "Connection: Keep-Alive / close" 
     1710void 
     1711cherokee_connection_set_keepalive (cherokee_connection_t *conn) 
     1712
     1713        ret_t              ret; 
     1714        char              *ptr; 
     1715        cuint_t            ptr_len; 
     1716        cherokee_server_t *srv    = CONN_SRV(conn); 
     1717        cherokee_thread_t *thread = CONN_THREAD(conn); 
     1718 
     1719        /* Check whether server allows keep-alive 
     1720         */ 
     1721        if (srv->keepalive == false) { 
     1722                conn->keepalive = 0; 
     1723                return; 
     1724        } 
     1725 
     1726        /* Check the Max concurrent Keep-Alive limit on this thread 
     1727         */ 
     1728        if (thread->conns_max > srv->conns_keepalive_max) { 
     1729                conn->keepalive = 0; 
     1730                return; 
     1731        } 
     1732 
     1733        /* Set Keep-alive according with the 'Connection' header 
    17181734         */ 
    17191735        ret = cherokee_header_get_known (&conn->header, header_connection, &ptr, &ptr_len); 
     
    17211737                if (strncasecmp (ptr, "close", 5) == 0) { 
    17221738                        conn->keepalive = 0; 
     1739                } else { 
     1740                        conn->keepalive = CONN_SRV(conn)->keepalive_max; 
    17231741                } 
    17241742        } else { 
    17251743                conn->keepalive = 0; 
    17261744        } 
    1727  
    1728         /* Don't use keepalive if the server is about to be overloaded 
    1729          */ 
    1730         if ((conn->keepalive) && 
    1731             (CONN_THREAD(conn)->conns_max > CONN_SRV(conn)->conns_keepalive_max)) 
    1732         { 
    1733                 conn->keepalive = 0; 
    1734         } 
     1745
     1746 
     1747 
     1748ret_t 
     1749cherokee_connection_parse_header (cherokee_connection_t *conn, cherokee_encoder_table_t *encoders) 
     1750
     1751        ret_t    ret; 
     1752        char    *ptr; 
     1753        cuint_t  ptr_len; 
    17351754 
    17361755        /* Look for "Range:"  
  • cherokee/trunk/cherokee/thread.c

    r1809 r1814  
    924924                        } 
    925925                         
     926                        /* Update the keep-alive property 
     927                         */ 
     928                        cherokee_connection_set_keepalive (conn); 
     929 
    926930                        /* Create the handler 
    927931                         */ 
     
    938942                                continue; 
    939943                        } 
    940                          
     944 
    941945                        /* Parse the rest of headers 
    942946                         */ 
     
    956960                         
    957961                case phase_init:  
    958                         /* Server's "Keep-Alive" could be turned "Off" 
    959                          */ 
    960                         if (conn->keepalive != 0) { 
    961                                 if (srv->keepalive == false)  
    962                                         conn->keepalive = 0; 
    963                         } 
    964  
    965962                        /* Look for the request 
    966963                         */ 
     
    19491946        new_connection->thread    = thd; 
    19501947        new_connection->server    = server; 
    1951         new_connection->keepalive = server->keepalive_max; 
    19521948        new_connection->vserver   = VSERVER(server->vservers.prev);  
    19531949