src/http/modules/ngx_http_static_module.c:102: error: Integer Overflow L1
  ([-oo, 0] - 1):unsigned64 by call to `ngx_open_cached_file`.

src/http/modules/ngx_http_static_module.c:89:5: Unknown value from: __infer_skip
87.     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
88. 
89.     ngx_memzero(&of, sizeof(ngx_open_file_info_t));
        ^
90. 
91.     of.read_ahead = clcf->read_ahead;

src/http/modules/ngx_http_static_module.c:98:9: Call
 96.     of.events = clcf->open_file_cache_events;
 97. 
 98.     if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
             ^
 99.         return NGX_HTTP_INTERNAL_SERVER_ERROR;
100.     }

src/http/ngx_http_core_module.c:2642:1: Parameter `*clcf->disable_symlinks_from->lengths`
  2640. 
  2641. 
  2642. ngx_int_t
        ^
  2643. ngx_http_set_disable_symlinks(ngx_http_request_t *r,
  2644.     ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of)

src/http/modules/ngx_http_static_module.c:102:9: Call
100.     }
101. 
102.     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
             ^
103.         != NGX_OK)
104.     {

src/core/ngx_open_file_cache.c:139:1: <LHS trace>
137. 
138. 
139. ngx_int_t
     ^
140. ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
141.     ngx_open_file_info_t *of, ngx_pool_t *pool)

src/core/ngx_open_file_cache.c:139:1: Parameter `cache->current`
  137. 
  138. 
  139. ngx_int_t
       ^
  140. ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
  141.     ngx_open_file_info_t *of, ngx_pool_t *pool)

src/core/ngx_open_file_cache.c:454:9: Binary operation: ([-oo, 0] - 1):unsigned64 by call to `ngx_open_cached_file` 
  452.         ngx_rbtree_delete(&cache->rbtree, &file->node);
  453. 
  454.         cache->current--;
               ^
  455. 
  456.         if (file->count == 0) {

ngx_int_t
ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
    ngx_open_file_info_t *of, ngx_pool_t *pool)
{
    time_t                          now;
    uint32_t                        hash;
    ngx_int_t                       rc;
    ngx_file_info_t                 fi;
    ngx_pool_cleanup_t             *cln;
    ngx_cached_open_file_t         *file;
    ngx_pool_cleanup_file_t        *clnf;
    ngx_open_file_cache_cleanup_t  *ofcln;
    of->fd = NGX_INVALID_FILE;
    of->err = 0;
    if (cache == NULL) {
        if (of->test_only) {
            if (ngx_file_info_wrapper(name, of, &fi, pool->log)
                == NGX_FILE_ERROR)
            {
                return NGX_ERROR;
            }
            of->uniq = ngx_file_uniq(&fi);
            of->mtime = ngx_file_mtime(&fi);
            of->size = ngx_file_size(&fi);
            of->fs_size = ngx_file_fs_size(&fi);
            of->is_dir = ngx_is_dir(&fi);
            of->is_file = ngx_is_file(&fi);
            of->is_link = ngx_is_link(&fi);
            of->is_exec = ngx_is_exec(&fi);
            return NGX_OK;
        }
        cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t));
        if (cln == NULL) {
            return NGX_ERROR;
        }
        rc = ngx_open_and_stat_file(name, of, pool->log);
        if (rc == NGX_OK && !of->is_dir) {
            cln->handler = ngx_pool_cleanup_file;
            clnf = cln->data;
            clnf->fd = of->fd;
            clnf->name = name->data;
            clnf->log = pool->log;
        }
        return rc;
    }
    cln = ngx_pool_cleanup_add(pool, sizeof(ngx_open_file_cache_cleanup_t));
    if (cln == NULL) {
        return NGX_ERROR;
    }
    now = ngx_time();
    hash = ngx_crc32_long(name->data, name->len);
    file = ngx_open_file_lookup(cache, name, hash);
    if (file) {
        file->uses++;
        ngx_queue_remove(&file->queue);
        if (file->fd == NGX_INVALID_FILE && file->err == 0 && !file->is_dir) {
            rc = ngx_open_and_stat_file(name, of, pool->log);
            if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
                goto failed;
            }
            goto add_event;
        }
        if (file->use_event
            || (file->event == NULL
                && (of->uniq == 0 || of->uniq == file->uniq)
                && now - file->created < of->valid
#if (NGX_HAVE_OPENAT)
                && of->disable_symlinks == file->disable_symlinks
                && of->disable_symlinks_from == file->disable_symlinks_from
#endif
            ))
        {
            if (file->err == 0) {
                of->fd = file->fd;
                of->uniq = file->uniq;
                of->mtime = file->mtime;
                of->size = file->size;
                of->is_dir = file->is_dir;
                of->is_file = file->is_file;
                of->is_link = file->is_link;
                of->is_exec = file->is_exec;
                of->is_directio = file->is_directio;
                if (!file->is_dir) {
                    file->count++;
                    ngx_open_file_add_event(cache, file, of, pool->log);
                }
            } else {
                of->err = file->err;
#if (NGX_HAVE_OPENAT)
                of->failed = file->disable_symlinks ? ngx_openat_file_n
                                                    : ngx_open_file_n;
#else
                of->failed = ngx_open_file_n;
#endif
            }
            goto found;
        }
        ngx_log_debug4(NGX_LOG_DEBUG_CORE, pool->log, 0,
                       "retest open file: %s, fd:%d, c:%d, e:%d",
                       file->name, file->fd, file->count, file->err);
        if (file->is_dir) {
            of->test_dir = 1;
        }
        of->fd = file->fd;
        of->uniq = file->uniq;
        rc = ngx_open_and_stat_file(name, of, pool->log);
        if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
            goto failed;
        }
        if (of->is_dir) {
            if (file->is_dir || file->err) {
                goto update;
            }
        } else if (of->err == 0) {
            if (file->is_dir || file->err) {
                goto add_event;
            }
            if (of->uniq == file->uniq) {
                if (file->event) {
                    file->use_event = 1;
                }
                of->is_directio = file->is_directio;
                goto update;
            }
        } else {
            if (file->err || file->is_dir) {
                goto update;
            }
        }
        if (file->count == 0) {
            ngx_open_file_del_event(file);
            if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
                ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
                              ngx_close_file_n " \"%V\" failed", name);
            }
            goto add_event;
        }
        ngx_rbtree_delete(&cache->rbtree, &file->node);
        cache->current--;
        file->close = 1;
        goto create;
    }
    rc = ngx_open_and_stat_file(name, of, pool->log);
    if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
        goto failed;
    }
create:
    if (cache->current >= cache->max) {
        ngx_expire_old_cached_files(cache, 0, pool->log);
    }
    file = ngx_alloc(sizeof(ngx_cached_open_file_t), pool->log);
    if (file == NULL) {
        goto failed;
    }
    file->name = ngx_alloc(name->len + 1, pool->log);
    if (file->name == NULL) {
        ngx_free(file);
        file = NULL;
        goto failed;
    }
    ngx_cpystrn(file->name, name->data, name->len + 1);
    file->node.key = hash;
    ngx_rbtree_insert(&cache->rbtree, &file->node);
    cache->current++;
    file->uses = 1;
    file->count = 0;
    file->use_event = 0;
    file->event = NULL;
add_event:
    ngx_open_file_add_event(cache, file, of, pool->log);
update:
    file->fd = of->fd;
    file->err = of->err;
#if (NGX_HAVE_OPENAT)
    file->disable_symlinks = of->disable_symlinks;
    file->disable_symlinks_from = of->disable_symlinks_from;
#endif
    if (of->err == 0) {
        file->uniq = of->uniq;
        file->mtime = of->mtime;
        file->size = of->size;
        file->close = 0;
        file->is_dir = of->is_dir;
        file->is_file = of->is_file;
        file->is_link = of->is_link;
        file->is_exec = of->is_exec;
        file->is_directio = of->is_directio;
        if (!of->is_dir) {
            file->count++;
        }
    }
    file->created = now;
found:
    file->accessed = now;
    ngx_queue_insert_head(&cache->expire_queue, &file->queue);
    ngx_log_debug5(NGX_LOG_DEBUG_CORE, pool->log, 0,
                   "cached open file: %s, fd:%d, c:%d, e:%d, u:%d",
                   file->name, file->fd, file->count, file->err, file->uses);
    if (of->err == 0) {
        if (!of->is_dir) {
            cln->handler = ngx_open_file_cleanup;
            ofcln = cln->data;
            ofcln->cache = cache;
            ofcln->file = file;
            ofcln->min_uses = of->min_uses;
            ofcln->log = pool->log;
        }
        return NGX_OK;
    }
    return NGX_ERROR;
failed:
    if (file) {
        ngx_rbtree_delete(&cache->rbtree, &file->node);
        cache->current--;
        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;
        }
    }
    if (of->fd != NGX_INVALID_FILE) {
        if (ngx_close_file(of->fd) == NGX_FILE_ERROR) {
            ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
                          ngx_close_file_n " \"%V\" failed", name);
        }
    }
    return NGX_ERROR;
}
['static ngx_int_t\nngx_http_static_handler(ngx_http_request_t *r)\n{\n    u_char                    *last, *location;\n    size_t                     root, len;\n    ngx_str_t                  path;\n    ngx_int_t                  rc;\n    ngx_uint_t                 level;\n    ngx_log_t                 *log;\n    ngx_buf_t                 *b;\n    ngx_chain_t                out;\n    ngx_open_file_info_t       of;\n    ngx_http_core_loc_conf_t  *clcf;\n    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {\n        return NGX_HTTP_NOT_ALLOWED;\n    }\n    if (r->uri.data[r->uri.len - 1] == \'/\') {\n        return NGX_DECLINED;\n    }\n    log = r->connection->log;\n    last = ngx_http_map_uri_to_path(r, &path, &root, 0);\n    if (last == NULL) {\n        return NGX_HTTP_INTERNAL_SERVER_ERROR;\n    }\n    path.len = last - path.data;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,\n                   "http filename: \\"%s\\"", path.data);\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    ngx_memzero(&of, sizeof(ngx_open_file_info_t));\n    of.read_ahead = clcf->read_ahead;\n    of.directio = clcf->directio;\n    of.valid = clcf->open_file_cache_valid;\n    of.min_uses = clcf->open_file_cache_min_uses;\n    of.errors = clcf->open_file_cache_errors;\n    of.events = clcf->open_file_cache_events;\n    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {\n        return NGX_HTTP_INTERNAL_SERVER_ERROR;\n    }\n    if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)\n        != NGX_OK)\n    {\n        switch (of.err) {\n        case 0:\n            return NGX_HTTP_INTERNAL_SERVER_ERROR;\n        case NGX_ENOENT:\n        case NGX_ENOTDIR:\n        case NGX_ENAMETOOLONG:\n            level = NGX_LOG_ERR;\n            rc = NGX_HTTP_NOT_FOUND;\n            break;\n        case NGX_EACCES:\n#if (NGX_HAVE_OPENAT)\n        case NGX_EMLINK:\n        case NGX_ELOOP:\n#endif\n            level = NGX_LOG_ERR;\n            rc = NGX_HTTP_FORBIDDEN;\n            break;\n        default:\n            level = NGX_LOG_CRIT;\n            rc = NGX_HTTP_INTERNAL_SERVER_ERROR;\n            break;\n        }\n        if (rc != NGX_HTTP_NOT_FOUND || clcf->log_not_found) {\n            ngx_log_error(level, log, of.err,\n                          "%s \\"%s\\" failed", of.failed, path.data);\n        }\n        return rc;\n    }\n    r->root_tested = !r->error_page;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd);\n    if (of.is_dir) {\n        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir");\n        ngx_http_clear_location(r);\n        r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));\n        if (r->headers_out.location == NULL) {\n            return NGX_HTTP_INTERNAL_SERVER_ERROR;\n        }\n        len = r->uri.len + 1;\n        if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) {\n            location = path.data + clcf->root.len;\n            *last = \'/\';\n        } else {\n            if (r->args.len) {\n                len += r->args.len + 1;\n            }\n            location = ngx_pnalloc(r->pool, len);\n            if (location == NULL) {\n                return NGX_HTTP_INTERNAL_SERVER_ERROR;\n            }\n            last = ngx_copy(location, r->uri.data, r->uri.len);\n            *last = \'/\';\n            if (r->args.len) {\n                *++last = \'?\';\n                ngx_memcpy(++last, r->args.data, r->args.len);\n            }\n        }\n        r->headers_out.location->value.len = len;\n        r->headers_out.location->value.data = location;\n        return NGX_HTTP_MOVED_PERMANENTLY;\n    }\n#if !(NGX_WIN32)\n    if (!of.is_file) {\n        ngx_log_error(NGX_LOG_CRIT, log, 0,\n                      "\\"%s\\" is not a regular file", path.data);\n        return NGX_HTTP_NOT_FOUND;\n    }\n#endif\n    if (r->method & NGX_HTTP_POST) {\n        return NGX_HTTP_NOT_ALLOWED;\n    }\n    rc = ngx_http_discard_request_body(r);\n    if (rc != NGX_OK) {\n        return rc;\n    }\n    log->action = "sending response to client";\n    r->headers_out.status = NGX_HTTP_OK;\n    r->headers_out.content_length_n = of.size;\n    r->headers_out.last_modified_time = of.mtime;\n    if (ngx_http_set_content_type(r) != NGX_OK) {\n        return NGX_HTTP_INTERNAL_SERVER_ERROR;\n    }\n    if (r != r->main && of.size == 0) {\n        return ngx_http_send_header(r);\n    }\n    r->allow_ranges = 1;\n    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));\n    if (b == NULL) {\n        return NGX_HTTP_INTERNAL_SERVER_ERROR;\n    }\n    b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));\n    if (b->file == NULL) {\n        return NGX_HTTP_INTERNAL_SERVER_ERROR;\n    }\n    rc = ngx_http_send_header(r);\n    if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {\n        return rc;\n    }\n    b->file_pos = 0;\n    b->file_last = of.size;\n    b->in_file = b->file_last ? 1: 0;\n    b->last_buf = (r == r->main) ? 1: 0;\n    b->last_in_chain = 1;\n    b->file->fd = of.fd;\n    b->file->name = path;\n    b->file->log = log;\n    b->file->directio = of.is_directio;\n    out.buf = b;\n    out.next = NULL;\n    return ngx_http_output_filter(r, &out);\n}', "ngx_int_t\nngx_http_set_disable_symlinks(ngx_http_request_t *r,\n    ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of)\n{\n#if (NGX_HAVE_OPENAT)\n    u_char     *p;\n    ngx_str_t   from;\n    of->disable_symlinks = clcf->disable_symlinks;\n    if (clcf->disable_symlinks_from == NULL) {\n        return NGX_OK;\n    }\n    if (ngx_http_complex_value(r, clcf->disable_symlinks_from, &from)\n        != NGX_OK)\n    {\n        return NGX_ERROR;\n    }\n    if (from.len == 0\n        || from.len > path->len\n        || ngx_memcmp(path->data, from.data, from.len) != 0)\n    {\n        return NGX_OK;\n    }\n    if (from.len == path->len) {\n        of->disable_symlinks = NGX_DISABLE_SYMLINKS_OFF;\n        return NGX_OK;\n    }\n    p = path->data + from.len;\n    if (*p == '/') {\n        of->disable_symlinks_from = from.len;\n        return NGX_OK;\n    }\n    p--;\n    if (*p == '/') {\n        of->disable_symlinks_from = from.len - 1;\n    }\n#endif\n    return NGX_OK;\n}", 'ngx_int_t\nngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,\n    ngx_open_file_info_t *of, ngx_pool_t *pool)\n{\n    time_t                          now;\n    uint32_t                        hash;\n    ngx_int_t                       rc;\n    ngx_file_info_t                 fi;\n    ngx_pool_cleanup_t             *cln;\n    ngx_cached_open_file_t         *file;\n    ngx_pool_cleanup_file_t        *clnf;\n    ngx_open_file_cache_cleanup_t  *ofcln;\n    of->fd = NGX_INVALID_FILE;\n    of->err = 0;\n    if (cache == NULL) {\n        if (of->test_only) {\n            if (ngx_file_info_wrapper(name, of, &fi, pool->log)\n                == NGX_FILE_ERROR)\n            {\n                return NGX_ERROR;\n            }\n            of->uniq = ngx_file_uniq(&fi);\n            of->mtime = ngx_file_mtime(&fi);\n            of->size = ngx_file_size(&fi);\n            of->fs_size = ngx_file_fs_size(&fi);\n            of->is_dir = ngx_is_dir(&fi);\n            of->is_file = ngx_is_file(&fi);\n            of->is_link = ngx_is_link(&fi);\n            of->is_exec = ngx_is_exec(&fi);\n            return NGX_OK;\n        }\n        cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t));\n        if (cln == NULL) {\n            return NGX_ERROR;\n        }\n        rc = ngx_open_and_stat_file(name, of, pool->log);\n        if (rc == NGX_OK && !of->is_dir) {\n            cln->handler = ngx_pool_cleanup_file;\n            clnf = cln->data;\n            clnf->fd = of->fd;\n            clnf->name = name->data;\n            clnf->log = pool->log;\n        }\n        return rc;\n    }\n    cln = ngx_pool_cleanup_add(pool, sizeof(ngx_open_file_cache_cleanup_t));\n    if (cln == NULL) {\n        return NGX_ERROR;\n    }\n    now = ngx_time();\n    hash = ngx_crc32_long(name->data, name->len);\n    file = ngx_open_file_lookup(cache, name, hash);\n    if (file) {\n        file->uses++;\n        ngx_queue_remove(&file->queue);\n        if (file->fd == NGX_INVALID_FILE && file->err == 0 && !file->is_dir) {\n            rc = ngx_open_and_stat_file(name, of, pool->log);\n            if (rc != NGX_OK && (of->err == 0 || !of->errors)) {\n                goto failed;\n            }\n            goto add_event;\n        }\n        if (file->use_event\n            || (file->event == NULL\n                && (of->uniq == 0 || of->uniq == file->uniq)\n                && now - file->created < of->valid\n#if (NGX_HAVE_OPENAT)\n                && of->disable_symlinks == file->disable_symlinks\n                && of->disable_symlinks_from == file->disable_symlinks_from\n#endif\n            ))\n        {\n            if (file->err == 0) {\n                of->fd = file->fd;\n                of->uniq = file->uniq;\n                of->mtime = file->mtime;\n                of->size = file->size;\n                of->is_dir = file->is_dir;\n                of->is_file = file->is_file;\n                of->is_link = file->is_link;\n                of->is_exec = file->is_exec;\n                of->is_directio = file->is_directio;\n                if (!file->is_dir) {\n                    file->count++;\n                    ngx_open_file_add_event(cache, file, of, pool->log);\n                }\n            } else {\n                of->err = file->err;\n#if (NGX_HAVE_OPENAT)\n                of->failed = file->disable_symlinks ? ngx_openat_file_n\n                                                    : ngx_open_file_n;\n#else\n                of->failed = ngx_open_file_n;\n#endif\n            }\n            goto found;\n        }\n        ngx_log_debug4(NGX_LOG_DEBUG_CORE, pool->log, 0,\n                       "retest open file: %s, fd:%d, c:%d, e:%d",\n                       file->name, file->fd, file->count, file->err);\n        if (file->is_dir) {\n            of->test_dir = 1;\n        }\n        of->fd = file->fd;\n        of->uniq = file->uniq;\n        rc = ngx_open_and_stat_file(name, of, pool->log);\n        if (rc != NGX_OK && (of->err == 0 || !of->errors)) {\n            goto failed;\n        }\n        if (of->is_dir) {\n            if (file->is_dir || file->err) {\n                goto update;\n            }\n        } else if (of->err == 0) {\n            if (file->is_dir || file->err) {\n                goto add_event;\n            }\n            if (of->uniq == file->uniq) {\n                if (file->event) {\n                    file->use_event = 1;\n                }\n                of->is_directio = file->is_directio;\n                goto update;\n            }\n        } else {\n            if (file->err || file->is_dir) {\n                goto update;\n            }\n        }\n        if (file->count == 0) {\n            ngx_open_file_del_event(file);\n            if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {\n                ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,\n                              ngx_close_file_n " \\"%V\\" failed", name);\n            }\n            goto add_event;\n        }\n        ngx_rbtree_delete(&cache->rbtree, &file->node);\n        cache->current--;\n        file->close = 1;\n        goto create;\n    }\n    rc = ngx_open_and_stat_file(name, of, pool->log);\n    if (rc != NGX_OK && (of->err == 0 || !of->errors)) {\n        goto failed;\n    }\ncreate:\n    if (cache->current >= cache->max) {\n        ngx_expire_old_cached_files(cache, 0, pool->log);\n    }\n    file = ngx_alloc(sizeof(ngx_cached_open_file_t), pool->log);\n    if (file == NULL) {\n        goto failed;\n    }\n    file->name = ngx_alloc(name->len + 1, pool->log);\n    if (file->name == NULL) {\n        ngx_free(file);\n        file = NULL;\n        goto failed;\n    }\n    ngx_cpystrn(file->name, name->data, name->len + 1);\n    file->node.key = hash;\n    ngx_rbtree_insert(&cache->rbtree, &file->node);\n    cache->current++;\n    file->uses = 1;\n    file->count = 0;\n    file->use_event = 0;\n    file->event = NULL;\nadd_event:\n    ngx_open_file_add_event(cache, file, of, pool->log);\nupdate:\n    file->fd = of->fd;\n    file->err = of->err;\n#if (NGX_HAVE_OPENAT)\n    file->disable_symlinks = of->disable_symlinks;\n    file->disable_symlinks_from = of->disable_symlinks_from;\n#endif\n    if (of->err == 0) {\n        file->uniq = of->uniq;\n        file->mtime = of->mtime;\n        file->size = of->size;\n        file->close = 0;\n        file->is_dir = of->is_dir;\n        file->is_file = of->is_file;\n        file->is_link = of->is_link;\n        file->is_exec = of->is_exec;\n        file->is_directio = of->is_directio;\n        if (!of->is_dir) {\n            file->count++;\n        }\n    }\n    file->created = now;\nfound:\n    file->accessed = now;\n    ngx_queue_insert_head(&cache->expire_queue, &file->queue);\n    ngx_log_debug5(NGX_LOG_DEBUG_CORE, pool->log, 0,\n                   "cached open file: %s, fd:%d, c:%d, e:%d, u:%d",\n                   file->name, file->fd, file->count, file->err, file->uses);\n    if (of->err == 0) {\n        if (!of->is_dir) {\n            cln->handler = ngx_open_file_cleanup;\n            ofcln = cln->data;\n            ofcln->cache = cache;\n            ofcln->file = file;\n            ofcln->min_uses = of->min_uses;\n            ofcln->log = pool->log;\n        }\n        return NGX_OK;\n    }\n    return NGX_ERROR;\nfailed:\n    if (file) {\n        ngx_rbtree_delete(&cache->rbtree, &file->node);\n        cache->current--;\n        if (file->count == 0) {\n            if (file->fd != NGX_INVALID_FILE) {\n                if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {\n                    ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,\n                                  ngx_close_file_n " \\"%s\\" failed",\n                                  file->name);\n                }\n            }\n            ngx_free(file->name);\n            ngx_free(file);\n        } else {\n            file->close = 1;\n        }\n    }\n    if (of->fd != NGX_INVALID_FILE) {\n        if (ngx_close_file(of->fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,\n                          ngx_close_file_n " \\"%V\\" failed", name);\n        }\n    }\n    return NGX_ERROR;\n}']