diff src/core/ngx_open_file_cache.c @ 374:67fa3851697b NGINX_0_6_31

nginx 0.6.31 *) Bugfix: nginx did not process FastCGI response if header was at the end of FastCGI record; bug appeared in 0.6.2. Thanks to Sergey Serov. *) Bugfix: a segmentation fault might occur in worker process if a file was deleted and the "open_file_cache_errors" directive was off.
author Igor Sysoev <http://sysoev.ru>
date Mon, 12 May 2008 00:00:00 +0400
parents 9a242235a80a
children edf1cb6c328e
line wrap: on
line diff
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -406,20 +406,27 @@ found:
 
 failed:
 
-    if (file && file->count == 0) {
+    if (file) {
         ngx_rbtree_delete(&cache->rbtree, &file->node);
 
         cache->current--;
 
-        if (file->fd != NGX_INVALID_FILE) {
-            if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
-                ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
-                              ngx_close_file_n " \"%s\" failed", file->name);
-            }
+        if (file->count == 0) {
+
+	    if (file->fd != NGX_INVALID_FILE) {
+		if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
+		    ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
+				  ngx_close_file_n " \"%s\" failed",
+                                  file->name);
+		}
+	    }
+
+            ngx_free(file->name);
+            ngx_free(file);
+
+        } else {
+            file->close = 1;
         }
-
-        ngx_free(file->name);
-        ngx_free(file);
     }
 
     if (of->fd != NGX_INVALID_FILE) {