add server.max_keep_alive_requests option

personal/stbuehler/wip
Thomas Porzelt 14 years ago
parent d3bfcf9d15
commit 736d8c6192
  1. 1
      include/lighttpd/connection.h
  2. 1
      include/lighttpd/plugin_core.h
  3. 6
      src/connection.c
  4. 1
      src/plugin_core.c

@ -56,6 +56,7 @@ struct connection {
guint max_idle;
ev_timer watcher;
} keep_alive_data;
guint keep_alive_requests;
/* I/O timeout data */
waitqueue_elem io_timeout_elem;

@ -13,6 +13,7 @@ enum core_options_t {
CORE_OPTION_SERVER_TAG,
CORE_OPTION_MAX_KEEP_ALIVE_IDLE,
CORE_OPTION_MAX_KEEP_ALIVE_REQUESTS,
CORE_OPTION_MIME_TYPES,

@ -122,6 +122,11 @@ static gboolean connection_handle_read(connection *con) {
con->keep_alive_data.timeout = 0;
ev_timer_stop(con->wrk->loop, &con->keep_alive_data.watcher);
con->keep_alive_requests++;
/* disable keep alive if limit is reached */
if (con->keep_alive_requests == CORE_OPTION(CORE_OPTION_MAX_KEEP_ALIVE_REQUESTS).number)
con->keep_alive = FALSE;
con->state = CON_STATE_READ_REQUEST_HEADER;
con->ts = CUR_TS(con->wrk);
@ -369,6 +374,7 @@ void connection_reset(connection *con) {
con->keep_alive_data.timeout = 0;
con->keep_alive_data.max_idle = 0;
ev_timer_stop(con->wrk->loop, &con->keep_alive_data.watcher);
con->keep_alive_requests = 0;
/* reset stats */
con->stats.bytes_in = G_GUINT64_CONSTANT(0);

@ -798,6 +798,7 @@ static const plugin_option options[] = {
{ "server.tag", VALUE_STRING, "lighttpd-2.0~sandbox", NULL, NULL },
{ "server.max_keep_alive_idle", VALUE_NUMBER, GINT_TO_POINTER(5), NULL, NULL },
{ "server.max_keep_alive_requests", VALUE_NUMBER, GINT_TO_POINTER(15), NULL, NULL },
{ "mime_types", VALUE_LIST, NULL, core_option_mime_types_parse, core_option_mime_types_free },

Loading…
Cancel
Save