diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2018-10-30 02:04:36 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2018-11-12 08:25:01 -0500 |
commit | f410431b58143dbb6c8282b94c693e23187ed925 (patch) | |
tree | 512357ed900bbedf505fa118504432feda280ed0 /src/mod_scgi.c | |
parent | 7e8beee57773fbf37b6a6dcd5bb0f3a701fa8843 (diff) | |
download | lighttpd-git-f410431b58143dbb6c8282b94c693e23187ed925.tar.gz |
[multiple] perf: use larger initial backend buffer
use larger initial backend buffer if the client request is large
Diffstat (limited to 'src/mod_scgi.c')
-rw-r--r-- | src/mod_scgi.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mod_scgi.c b/src/mod_scgi.c index da4033b4..d98a9676 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -132,7 +132,11 @@ static int scgi_env_add_uwsgi(void *venv, const char *key, size_t key_len, const len = 2 + key_len + 2 + val_len; - buffer_string_prepare_append(env, len); + if (buffer_string_space(env) < len) { + size_t extend = env->size * 2 - buffer_string_length(env); + extend = extend > len ? extend : len + 4095; + buffer_string_prepare_append(env, extend); + } uwlen = uwsgi_htole16((uint16_t)key_len); buffer_append_string_len(env, (char *)&uwlen, 2); @@ -155,6 +159,10 @@ static handler_t scgi_create_env(server *srv, handler_ctx *hctx) { : scgi_env_add_uwsgi; size_t offset; + if ((off_t)buffer_string_space(b) < con->read_queue->bytes_out - hctx->wb->bytes_in) { + buffer_string_prepare_copy(b, ((size_t)(con->read_queue->bytes_out - hctx->wb->bytes_in + 4095) & ~4095uL)-1); + } + /* save space for 9 digits (plus ':'), though incoming HTTP request * currently limited to 64k (65535, so 5 chars) */ buffer_copy_string_len(b, CONST_STR_LEN(" ")); |