Browse Source

[multiple] perf: use larger initial backend buffer

use larger initial backend buffer if the client request is large
personal/stbuehler/fix-fdevent
Glenn Strauss 4 years ago
parent
commit
f410431b58
  1. 4
      src/mod_fastcgi.c
  2. 4
      src/mod_proxy.c
  3. 10
      src/mod_scgi.c

4
src/mod_fastcgi.c

@ -242,6 +242,10 @@ static handler_t fcgi_create_env(server *srv, handler_ctx *hctx) {
beginRecord.body.flags = 0;
memset(beginRecord.body.reserved, 0, sizeof(beginRecord.body.reserved));
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);
}
buffer_copy_string_len(b, (const char *)&beginRecord, sizeof(beginRecord));
fcgi_header(&header, FCGI_PARAMS, request_id, 0, 0); /*(set aside space to fill in later)*/
buffer_append_string_len(b, (const char *)&header, sizeof(header));

4
src/mod_proxy.c

@ -714,6 +714,10 @@ static handler_t proxy_create_env(server *srv, gw_handler_ctx *gwhctx) {
const int upgrade = hctx->conf.header.upgrade
&& (NULL != http_header_request_get(con, HTTP_HEADER_UPGRADE, CONST_STR_LEN("Upgrade")));
if ((off_t)buffer_string_space(b) < con->read_queue->bytes_out - hctx->gw.wb->bytes_in) {
buffer_string_prepare_copy(b, ((size_t)(con->read_queue->bytes_out - hctx->gw.wb->bytes_in + 4095) & ~4095uL)-1);
}
/* build header */
/* request line */

10
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(" "));

Loading…
Cancel
Save