diff options
author | Stefan Bühler <stbuehler@web.de> | 2009-04-24 19:22:16 +0000 |
---|---|---|
committer | Stefan Bühler <stbuehler@web.de> | 2009-04-24 19:22:16 +0000 |
commit | d793237e3664d1ae17c059265ff7a58cb68c0bae (patch) | |
tree | 60538a8ca5b0cef484f2c144b4afce494c1495ae | |
parent | 2873320bd790ce90d3c5a583bb3d4acc3d4bc53b (diff) | |
download | lighttpd-git-d793237e3664d1ae17c059265ff7a58cb68c0bae.tar.gz |
Fix bug with FastCGI request id overflow under high load; just use always id 1 as we don't use multiplexing. (thx jgray)
git-svn-id: svn+ssh://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2477 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/mod_fastcgi.c | 63 |
2 files changed, 2 insertions, 62 deletions
@@ -25,6 +25,7 @@ NEWS * mod_magnet: Add env["request.remote-ip"] (fixes #1740) * mod_magnet: Add env["request.path-info"] * Change name/version separator back to "/" (affects every place where the version is printed) + * Fix bug with FastCGI request id overflow under high load; just use always id 1 as we don't use multiplexing. (thx jgray) - 1.4.22 - 2009-03-07 * Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533) diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 210dde3c..60b7a562 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -318,12 +318,6 @@ typedef struct { } plugin_config; typedef struct { - size_t *ptr; - size_t used; - size_t size; -} buffer_uint; - -typedef struct { char **ptr; size_t size; @@ -333,7 +327,6 @@ typedef struct { /* generic plugin data, shared between all connections */ typedef struct { PLUGIN_DATA; - buffer_uint fcgi_request_id; buffer *fcgi_env; @@ -635,12 +628,9 @@ INIT_FUNC(mod_fastcgi_init) { FREE_FUNC(mod_fastcgi_free) { plugin_data *p = p_d; - buffer_uint *r = &(p->fcgi_request_id); UNUSED(srv); - if (r->ptr) free(r->ptr); - buffer_free(p->fcgi_env); buffer_free(p->path); buffer_free(p->parse_response); @@ -1433,51 +1423,6 @@ static int fcgi_set_state(server *srv, handler_ctx *hctx, fcgi_connection_state_ } -static size_t fcgi_requestid_new(server *srv, plugin_data *p) { - size_t m = 0; - size_t i; - buffer_uint *r = &(p->fcgi_request_id); - - UNUSED(srv); - - for (i = 0; i < r->used; i++) { - if (r->ptr[i] > m) m = r->ptr[i]; - } - - if (r->size == 0) { - r->size = 16; - r->ptr = malloc(sizeof(*r->ptr) * r->size); - } else if (r->used == r->size) { - r->size += 16; - r->ptr = realloc(r->ptr, sizeof(*r->ptr) * r->size); - } - - r->ptr[r->used++] = ++m; - - return m; -} - -static int fcgi_requestid_del(server *srv, plugin_data *p, size_t request_id) { - size_t i; - buffer_uint *r = &(p->fcgi_request_id); - - UNUSED(srv); - - for (i = 0; i < r->used; i++) { - if (r->ptr[i] == request_id) break; - } - - if (i != r->used) { - /* found */ - - if (i != r->used - 1) { - r->ptr[i] = r->ptr[r->used - 1]; - } - r->used--; - } - - return 0; -} static void fcgi_connection_close(server *srv, handler_ctx *hctx) { plugin_data *p; connection *con; @@ -1494,10 +1439,6 @@ static void fcgi_connection_close(server *srv, handler_ctx *hctx) { srv->cur_fds--; } - if (hctx->request_id != 0) { - fcgi_requestid_del(srv, p, hctx->request_id); - } - if (hctx->host && hctx->proc) { if (hctx->got_proc) { /* after the connect the process gets a load */ @@ -1555,8 +1496,6 @@ static int fcgi_reconnect(server *srv, handler_ctx *hctx) { hctx->fd = -1; } - fcgi_requestid_del(srv, p, hctx->request_id); - fcgi_set_state(srv, hctx, FCGI_STATE_INIT); hctx->request_id = 0; @@ -3018,7 +2957,7 @@ static handler_t fcgi_write_request(server *srv, handler_ctx *hctx) { /* move the proc-list entry down the list */ if (hctx->request_id == 0) { - hctx->request_id = fcgi_requestid_new(srv, p); + hctx->request_id = 1; /* always use id 1 as we don't use multiplexing */ } else { log_error_write(srv, __FILE__, __LINE__, "sd", "fcgi-request is already in use:", hctx->request_id); |