Welcome! Log In Create A New Profile

Advanced

[nginx] Fixed "zero size buf in output" alerts.

Maxim Dounin
February 10, 2014 08:38AM
details: http://hg.nginx.org/nginx/rev/3b7463b08747
branches: stable-1.4
changeset: 5563:3b7463b08747
user: Maxim Dounin <mdounin@mdounin.ru>
date: Sat Jan 04 03:32:22 2014 +0400
description:
Fixed "zero size buf in output" alerts.

If a request had an empty request body (with Content-Length: 0), and there
were preread data available (e.g., due to a pipelined request in the buffer),
the "zero size buf in output" alert might be logged while proxying the
request to an upstream.

Similar alerts appeared with client_body_in_file_only if a request had an
empty request body.

diffstat:

src/http/ngx_http_request_body.c | 70 ++++++++++++++++++++++++---------------
1 files changed, 43 insertions(+), 27 deletions(-)

diffs (96 lines):

diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -150,21 +150,27 @@ ngx_http_read_client_request_body(ngx_ht
goto done;
}

- cl = ngx_chain_get_free_buf(r->pool, &rb->free);
- if (cl == NULL) {
- rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
- goto done;
+ if (rb->temp_file->file.offset != 0) {
+
+ cl = ngx_chain_get_free_buf(r->pool, &rb->free);
+ if (cl == NULL) {
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
+ }
+
+ b = cl->buf;
+
+ ngx_memzero(b, sizeof(ngx_buf_t));
+
+ b->in_file = 1;
+ b->file_last = rb->temp_file->file.offset;
+ b->file = &rb->temp_file->file;
+
+ rb->bufs = cl;
+
+ } else {
+ rb->bufs = NULL;
}
-
- b = cl->buf;
-
- ngx_memzero(b, sizeof(ngx_buf_t));
-
- b->in_file = 1;
- b->file_last = rb->temp_file->file.offset;
- b->file = &rb->temp_file->file;
-
- rb->bufs = cl;
}

post_handler(r);
@@ -375,20 +381,26 @@ ngx_http_do_read_client_request_body(ngx
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

- cl = ngx_chain_get_free_buf(r->pool, &rb->free);
- if (cl == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ if (rb->temp_file->file.offset != 0) {
+
+ cl = ngx_chain_get_free_buf(r->pool, &rb->free);
+ if (cl == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ b = cl->buf;
+
+ ngx_memzero(b, sizeof(ngx_buf_t));
+
+ b->in_file = 1;
+ b->file_last = rb->temp_file->file.offset;
+ b->file = &rb->temp_file->file;
+
+ rb->bufs = cl;
+
+ } else {
+ rb->bufs = NULL;
}
-
- b = cl->buf;
-
- ngx_memzero(b, sizeof(ngx_buf_t));
-
- b->in_file = 1;
- b->file_last = rb->temp_file->file.offset;
- b->file = &rb->temp_file->file;
-
- rb->bufs = cl;
}

r->read_event_handler = ngx_http_block_reading;
@@ -843,6 +855,10 @@ ngx_http_request_body_length_filter(ngx_

for (cl = in; cl; cl = cl->next) {

+ if (rb->rest == 0) {
+ break;
+ }
+
tl = ngx_chain_get_free_buf(r->pool, &rb->free);
if (tl == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Fixed "zero size buf in output" alerts.

Maxim Dounin 493 February 10, 2014 08:38AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 135
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready