Changeset 1814
- Timestamp:
- 08/14/08 13:50:04 (3 months ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/connection-protected.h (modified) (1 diff)
- cherokee/trunk/cherokee/connection.c (modified) (2 diffs)
- cherokee/trunk/cherokee/thread.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r1812 r1814 1 1 2008-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. 2 5 3 6 * cherokee/server.c (add_vserver): Adds a sanity check. It makes cherokee/trunk/cherokee/connection-protected.h
r1788 r1814 224 224 ret_t cherokee_connection_check_only_secure (cherokee_connection_t *conn, cherokee_config_entry_t *config_entry); 225 225 ret_t cherokee_connection_check_http_method (cherokee_connection_t *conn, cherokee_config_entry_t *config_entry); 226 void cherokee_connection_set_keepalive (cherokee_connection_t *conn); 226 227 227 228 /* Iteration cherokee/trunk/cherokee/connection.c
r1806 r1814 1708 1708 1709 1709 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" 1710 void 1711 cherokee_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 1718 1734 */ 1719 1735 ret = cherokee_header_get_known (&conn->header, header_connection, &ptr, &ptr_len); … … 1721 1737 if (strncasecmp (ptr, "close", 5) == 0) { 1722 1738 conn->keepalive = 0; 1739 } else { 1740 conn->keepalive = CONN_SRV(conn)->keepalive_max; 1723 1741 } 1724 1742 } else { 1725 1743 conn->keepalive = 0; 1726 1744 } 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 1748 ret_t 1749 cherokee_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; 1735 1754 1736 1755 /* Look for "Range:" cherokee/trunk/cherokee/thread.c
r1809 r1814 924 924 } 925 925 926 /* Update the keep-alive property 927 */ 928 cherokee_connection_set_keepalive (conn); 929 926 930 /* Create the handler 927 931 */ … … 938 942 continue; 939 943 } 940 944 941 945 /* Parse the rest of headers 942 946 */ … … 956 960 957 961 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 965 962 /* Look for the request 966 963 */ … … 1949 1946 new_connection->thread = thd; 1950 1947 new_connection->server = server; 1951 new_connection->keepalive = server->keepalive_max;1952 1948 new_connection->vserver = VSERVER(server->vservers.prev); 1953 1949