diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-04-29 22:15:23 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-04-29 22:15:23 +0400 |
commit | a327841bff65988519536b047c79dbd189c9c3d6 (patch) | |
tree | 8d42c832f961aeebaaf145a3a3de75d10ebfff7a /src/core/ngx_open_file_cache.c | |
parent | ada9190ed84948cd101c7b30cbb4695dd6ef76b4 (diff) |
fix segfault when file is deleted and open_file_cache_errors is off
Diffstat (limited to 'src/core/ngx_open_file_cache.c')
-rw-r--r-- | src/core/ngx_open_file_cache.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c index a1692f101..baf546f07 100644 --- 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) { - ngx_free(file->name); - ngx_free(file); + 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; + } } if (of->fd != NGX_INVALID_FILE) { |