]> git.kaiwu.me - nginx.git/commitdiff
Cache: c->reading flag introduced.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 27 Oct 2014 18:14:07 +0000 (21:14 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 27 Oct 2014 18:14:07 +0000 (21:14 +0300)
It replaces c->buf in checks in ngx_http_file_cache_open(), making it possible
to reopen the file without clearing c->buf.  No functional changes.

src/http/ngx_http_cache.h
src/http/ngx_http_file_cache.c

index a5886631b38c9ed80affa4be3d3cf87f9b88507b..b65fd493fd64768ce07e4996c41306f42da3199a 100644 (file)
@@ -101,6 +101,7 @@ struct ngx_http_cache_s {
     unsigned                         updating:1;
     unsigned                         exists:1;
     unsigned                         temp_file:1;
+    unsigned                         reading:1;
 };
 
 
index e1b16e9c6f26be8c87a7f9c50c92fcb2fee11dbb..60ca6e42b3dc58889420fc2dc398a6831771302e 100644 (file)
@@ -259,7 +259,7 @@ ngx_http_file_cache_open(ngx_http_request_t *r)
         return NGX_AGAIN;
     }
 
-    if (c->buf) {
+    if (c->reading) {
         return ngx_http_file_cache_read(r, c);
     }
 
@@ -620,9 +620,12 @@ ngx_http_file_cache_aio_read(ngx_http_request_t *r, ngx_http_cache_t *c)
     n = ngx_file_aio_read(&c->file, c->buf->pos, c->body_start, 0, r->pool);
 
     if (n != NGX_AGAIN) {
+        c->reading = 0;
         return n;
     }
 
+    c->reading = 1;
+
     c->file.aio->data = r;
     c->file.aio->handler = ngx_http_cache_aio_event_handler;