Closed iframist closed 14 years ago
Hi, Nginx complains about empty buffer when using empty $memc_value (set $memc_value '';)
2010/10/27 08:50:11 [alert] 5827#0: *3061 zero size buf in output t:0 r:0 f:0 ...
Solution: avoid creating new empty buffer if value length is 0:
--- src/ngx_http_memc_request.c.ORiG 2010-09-14 02:38:58.000000000 -0400 +++ src/ngx_http_memc_request.c 2010-10-27 12:34:48.000000000 -0400 @@ -177,28 +177,30 @@ *b->last++ = CR; *b->last++ = LF; if (memc_value_vv) { - dd("copy $memc_value to the request"); - b = ngx_calloc_buf(r->pool); - - if (b == NULL) { - return NGX_ERROR; - } - - b->memory = 1; - - b->start = b->pos = memc_value_vv->data; - b->last = b->end = b->start + memc_value_vv->len; - - cl = ngx_alloc_chain_link(r->pool); - if (cl == NULL) { - return NGX_ERROR; - } - - cl->buf = b; - cl->next = NULL; - - *ll = cl; - ll = &cl->next; + if (memc_value_vv->len) { + dd("copy $memc_value to the request"); + b = ngx_calloc_buf(r->pool); + + if (b == NULL) { + return NGX_ERROR; + } + + b->memory = 1; + + b->start = b->pos = memc_value_vv->data; + b->last = b->end = b->start + memc_value_vv->len; + + cl = ngx_alloc_chain_link(r->pool); + if (cl == NULL) { + return NGX_ERROR; + } + + cl->buf = b; + cl->next = NULL; + + *ll = cl; + ll = &cl->next; + } } else { /* to preserve the r->request_body->bufs untouched */
Already applied your patch in GitHub. Thanks!
Hi, Nginx complains about empty buffer when using empty $memc_value (set $memc_value '';)
2010/10/27 08:50:11 [alert] 5827#0: *3061 zero size buf in output t:0 r:0 f:0 ...
Solution: avoid creating new empty buffer if value length is 0: