]> git.kaiwu.me - nginx.git/commitdiff
do not pass buf with empty cached response,
authorIgor Sysoev <igor@sysoev.ru>
Tue, 15 Sep 2009 15:12:03 +0000 (15:12 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 15 Sep 2009 15:12:03 +0000 (15:12 +0000)
this fixes "zero size buf in output" alert

src/http/ngx_http_file_cache.c

index a6271a8e93f22c2cfd78ffe747e57a3dbcce901c..ca333fc14e488c493bddfea92a9af6f985770212 100644 (file)
@@ -767,6 +767,7 @@ ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf)
 ngx_int_t
 ngx_http_cache_send(ngx_http_request_t *r)
 {
+    off_t              size;
     ngx_int_t          rc;
     ngx_buf_t         *b;
     ngx_chain_t        out;
@@ -795,10 +796,15 @@ ngx_http_cache_send(ngx_http_request_t *r)
         return rc;
     }
 
+    size = c->length - c->body_start;
+    if (size == 0) {
+        return rc;
+    }
+
     b->file_pos = c->body_start;
     b->file_last = c->length;
 
-    b->in_file = (c->length - c->body_start) ? 1: 0;
+    b->in_file = size ? 1: 0;
     b->last_buf = (r == r->main) ? 1: 0;
     b->last_in_chain = 1;