src/http/ngx_http_file_cache.c:1954: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned64 by call to `ngx_http_file_cache_forced_expire`.

src/http/ngx_http_file_cache.c:1930:25: Call
1928.     cache->files = 0;
1929. 
1930.     next = (ngx_msec_t) ngx_http_file_cache_expire(cache) * 1000;
                              ^
1931. 
1932.     if (next == 0) {

src/http/ngx_http_file_cache.c:1813:13: Call
  1811. 
  1812.         if (fcn->count == 0) {
  1813.             ngx_http_file_cache_delete(cache, q, name);
                    ^
  1814.             goto next;
  1815.         }

src/http/ngx_http_file_cache.c:1890:9: Call
    1888.         fcn->count++;
    1889.         fcn->deleting = 1;
    1890.         ngx_shmtx_unlock(&cache->shpool->mutex);
                  ^
    1891. 
    1892.         len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;

src/core/ngx_shmtx.c:136:1: Parameter `mtx->spin`
      134. 
      135. 
      136. void
           ^
      137. ngx_shmtx_unlock(ngx_shmtx_t *mtx)
      138. {

src/http/ngx_http_file_cache.c:1903:9: Call
    1901.         }
    1902. 
    1903.         ngx_shmtx_lock(&cache->shpool->mutex);
                  ^
    1904.         fcn->count--;
    1905.         fcn->deleting = 0;

src/core/ngx_shmtx.c:69:1: Parameter `mtx->spin`
      67. 
      68. 
      69. void
          ^
      70. ngx_shmtx_lock(ngx_shmtx_t *mtx)
      71. {

src/http/ngx_http_file_cache.c:1938:9: Call
1936. 
1937.     for ( ;; ) {
1938.         ngx_shmtx_lock(&cache->shpool->mutex);
              ^
1939. 
1940.         size = cache->sh->size;

src/core/ngx_shmtx.c:69:1: Parameter `mtx->spin`
  67. 
  68. 
  69. void
      ^
  70. ngx_shmtx_lock(ngx_shmtx_t *mtx)
  71. {

src/http/ngx_http_file_cache.c:1944:9: Call
1942.         watermark = cache->sh->watermark;
1943. 
1944.         ngx_shmtx_unlock(&cache->shpool->mutex);
              ^
1945. 
1946.         ngx_log_debug3(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,

src/core/ngx_shmtx.c:136:1: Parameter `mtx->spin`
  134. 
  135. 
  136. void
       ^
  137. ngx_shmtx_unlock(ngx_shmtx_t *mtx)
  138. {

src/http/ngx_http_file_cache.c:1954:16: Call
1952.         }
1953. 
1954.         wait = ngx_http_file_cache_forced_expire(cache);
                     ^
1955. 
1956.         if (wait > 0) {

src/http/ngx_http_file_cache.c:1692:1: Parameter `cache->sh->count`
  1690. 
  1691. 
  1692. static time_t
        ^
  1693. ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache)
  1694. {

src/http/ngx_http_file_cache.c:1733:13: Call
  1731. 
  1732.         if (fcn->count == 0) {
  1733.             ngx_http_file_cache_delete(cache, q, name);
                    ^
  1734.             wait = 0;
  1735. 

src/http/ngx_http_file_cache.c:1866:1: <LHS trace>
1864. 
1865. 
1866. static void
      ^
1867. ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
1868.     u_char *name)

src/http/ngx_http_file_cache.c:1866:1: Parameter `cache->sh->count`
    1864. 
    1865. 
    1866. static void
          ^
    1867. ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
    1868.     u_char *name)

src/http/ngx_http_file_cache.c:1912:9: Binary operation: ([0, +oo] - 1):unsigned64 by call to `ngx_http_file_cache_forced_expire` 
    1910.         ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
    1911.         ngx_slab_free_locked(cache->shpool, fcn);
    1912.         cache->sh->count--;
                  ^
    1913.     }
    1914. }

static void
ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
    u_char *name)
{
    u_char                      *p;
    size_t                       len;
    ngx_path_t                  *path;
    ngx_http_file_cache_node_t  *fcn;
    fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);
    if (fcn->exists) {
        cache->sh->size -= fcn->fs_size;
        path = cache->path;
        p = name + path->name.len + 1 + path->len;
        p = ngx_hex_dump(p, (u_char *) &fcn->node.key,
                         sizeof(ngx_rbtree_key_t));
        len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);
        p = ngx_hex_dump(p, fcn->key, len);
        *p = '\0';
        fcn->count++;
        fcn->deleting = 1;
        ngx_shmtx_unlock(&cache->shpool->mutex);
        len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;
        ngx_create_hashed_filename(path, name, len);
        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
                       "http file cache expire: \"%s\"", name);
        if (ngx_delete_file(name) == NGX_FILE_ERROR) {
            ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno,
                          ngx_delete_file_n " \"%s\" failed", name);
        }
        ngx_shmtx_lock(&cache->shpool->mutex);
        fcn->count--;
        fcn->deleting = 0;
    }
    if (fcn->count == 0) {
        ngx_queue_remove(q);
        ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
        ngx_slab_free_locked(cache->shpool, fcn);
        cache->sh->count--;
    }
}
['static ngx_msec_t\nngx_http_file_cache_manager(void *data)\n{\n    ngx_http_file_cache_t  *cache = data;\n    off_t       size;\n    time_t      wait;\n    ngx_msec_t  elapsed, next;\n    ngx_uint_t  count, watermark;\n    cache->last = ngx_current_msec;\n    cache->files = 0;\n    next = (ngx_msec_t) ngx_http_file_cache_expire(cache) * 1000;\n    if (next == 0) {\n        next = cache->manager_sleep;\n        goto done;\n    }\n    for ( ;; ) {\n        ngx_shmtx_lock(&cache->shpool->mutex);\n        size = cache->sh->size;\n        count = cache->sh->count;\n        watermark = cache->sh->watermark;\n        ngx_shmtx_unlock(&cache->shpool->mutex);\n        ngx_log_debug3(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                       "http file cache size: %O c:%ui w:%i",\n                       size, count, (ngx_int_t) watermark);\n        if (size < cache->max_size && count < watermark) {\n            break;\n        }\n        wait = ngx_http_file_cache_forced_expire(cache);\n        if (wait > 0) {\n            next = (ngx_msec_t) wait * 1000;\n            break;\n        }\n        if (ngx_quit || ngx_terminate) {\n            break;\n        }\n        if (++cache->files >= cache->manager_files) {\n            next = cache->manager_sleep;\n            break;\n        }\n        ngx_time_update();\n        elapsed = ngx_abs((ngx_msec_int_t) (ngx_current_msec - cache->last));\n        if (elapsed >= cache->manager_threshold) {\n            next = cache->manager_sleep;\n            break;\n        }\n    }\ndone:\n    elapsed = ngx_abs((ngx_msec_int_t) (ngx_current_msec - cache->last));\n    ngx_log_debug3(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                   "http file cache manager: %ui e:%M n:%M",\n                   cache->files, elapsed, next);\n    return next;\n}', 'static time_t\nngx_http_file_cache_expire(ngx_http_file_cache_t *cache)\n{\n    u_char                      *name, *p;\n    size_t                       len;\n    time_t                       now, wait;\n    ngx_path_t                  *path;\n    ngx_msec_t                   elapsed;\n    ngx_queue_t                 *q;\n    ngx_http_file_cache_node_t  *fcn;\n    u_char                       key[2 * NGX_HTTP_CACHE_KEY_LEN];\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                   "http file cache expire");\n    path = cache->path;\n    len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;\n    name = ngx_alloc(len + 1, ngx_cycle->log);\n    if (name == NULL) {\n        return 10;\n    }\n    ngx_memcpy(name, path->name.data, path->name.len);\n    now = ngx_time();\n    ngx_shmtx_lock(&cache->shpool->mutex);\n    for ( ;; ) {\n        if (ngx_quit || ngx_terminate) {\n            wait = 1;\n            break;\n        }\n        if (ngx_queue_empty(&cache->sh->queue)) {\n            wait = 10;\n            break;\n        }\n        q = ngx_queue_last(&cache->sh->queue);\n        fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);\n        wait = fcn->expire - now;\n        if (wait > 0) {\n            wait = wait > 10 ? 10 : wait;\n            break;\n        }\n        ngx_log_debug6(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                       "http file cache expire: #%d %d %02xd%02xd%02xd%02xd",\n                       fcn->count, fcn->exists,\n                       fcn->key[0], fcn->key[1], fcn->key[2], fcn->key[3]);\n        if (fcn->count == 0) {\n            ngx_http_file_cache_delete(cache, q, name);\n            goto next;\n        }\n        if (fcn->deleting) {\n            wait = 1;\n            break;\n        }\n        p = ngx_hex_dump(key, (u_char *) &fcn->node.key,\n                         sizeof(ngx_rbtree_key_t));\n        len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);\n        (void) ngx_hex_dump(p, fcn->key, len);\n        ngx_queue_remove(q);\n        fcn->expire = ngx_time() + cache->inactive;\n        ngx_queue_insert_head(&cache->sh->queue, &fcn->queue);\n        ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,\n                      "ignore long locked inactive cache entry %*s, count:%d",\n                      (size_t) 2 * NGX_HTTP_CACHE_KEY_LEN, key, fcn->count);\nnext:\n        if (++cache->files >= cache->manager_files) {\n            wait = 0;\n            break;\n        }\n        ngx_time_update();\n        elapsed = ngx_abs((ngx_msec_int_t) (ngx_current_msec - cache->last));\n        if (elapsed >= cache->manager_threshold) {\n            wait = 0;\n            break;\n        }\n    }\n    ngx_shmtx_unlock(&cache->shpool->mutex);\n    ngx_free(name);\n    return wait;\n}', 'static void\nngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,\n    u_char *name)\n{\n    u_char                      *p;\n    size_t                       len;\n    ngx_path_t                  *path;\n    ngx_http_file_cache_node_t  *fcn;\n    fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);\n    if (fcn->exists) {\n        cache->sh->size -= fcn->fs_size;\n        path = cache->path;\n        p = name + path->name.len + 1 + path->len;\n        p = ngx_hex_dump(p, (u_char *) &fcn->node.key,\n                         sizeof(ngx_rbtree_key_t));\n        len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);\n        p = ngx_hex_dump(p, fcn->key, len);\n        *p = \'\\0\';\n        fcn->count++;\n        fcn->deleting = 1;\n        ngx_shmtx_unlock(&cache->shpool->mutex);\n        len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;\n        ngx_create_hashed_filename(path, name, len);\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                       "http file cache expire: \\"%s\\"", name);\n        if (ngx_delete_file(name) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, ngx_errno,\n                          ngx_delete_file_n " \\"%s\\" failed", name);\n        }\n        ngx_shmtx_lock(&cache->shpool->mutex);\n        fcn->count--;\n        fcn->deleting = 0;\n    }\n    if (fcn->count == 0) {\n        ngx_queue_remove(q);\n        ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);\n        ngx_slab_free_locked(cache->shpool, fcn);\n        cache->sh->count--;\n    }\n}', 'void\nngx_shmtx_unlock(ngx_shmtx_t *mtx)\n{\n    if (mtx->spin != (ngx_uint_t) -1) {\n        ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, "shmtx unlock");\n    }\n    if (ngx_atomic_cmp_set(mtx->lock, ngx_pid, 0)) {\n        ngx_shmtx_wakeup(mtx);\n    }\n}', 'void\nngx_shmtx_lock(ngx_shmtx_t *mtx)\n{\n    ngx_uint_t         i, n;\n    ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, "shmtx lock");\n    for ( ;; ) {\n        if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) {\n            return;\n        }\n        if (ngx_ncpu > 1) {\n            for (n = 1; n < mtx->spin; n <<= 1) {\n                for (i = 0; i < n; i++) {\n                    ngx_cpu_pause();\n                }\n                if (*mtx->lock == 0\n                    && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid))\n                {\n                    return;\n                }\n            }\n        }\n#if (NGX_HAVE_POSIX_SEM)\n        if (mtx->semaphore) {\n            (void) ngx_atomic_fetch_add(mtx->wait, 1);\n            if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid)) {\n                (void) ngx_atomic_fetch_add(mtx->wait, -1);\n                return;\n            }\n            ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,\n                           "shmtx wait %uA", *mtx->wait);\n            while (sem_wait(&mtx->sem) == -1) {\n                ngx_err_t  err;\n                err = ngx_errno;\n                if (err != NGX_EINTR) {\n                    ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err,\n                                  "sem_wait() failed while waiting on shmtx");\n                    break;\n                }\n            }\n            ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,\n                           "shmtx awoke");\n            continue;\n        }\n#endif\n        ngx_sched_yield();\n    }\n}', 'static time_t\nngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache)\n{\n    u_char                      *name;\n    size_t                       len;\n    time_t                       wait;\n    ngx_uint_t                   tries;\n    ngx_path_t                  *path;\n    ngx_queue_t                 *q;\n    ngx_http_file_cache_node_t  *fcn;\n    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                   "http file cache forced expire");\n    path = cache->path;\n    len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;\n    name = ngx_alloc(len + 1, ngx_cycle->log);\n    if (name == NULL) {\n        return 10;\n    }\n    ngx_memcpy(name, path->name.data, path->name.len);\n    wait = 10;\n    tries = 20;\n    ngx_shmtx_lock(&cache->shpool->mutex);\n    for (q = ngx_queue_last(&cache->sh->queue);\n         q != ngx_queue_sentinel(&cache->sh->queue);\n         q = ngx_queue_prev(q))\n    {\n        fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);\n        ngx_log_debug6(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,\n                  "http file cache forced expire: #%d %d %02xd%02xd%02xd%02xd",\n                  fcn->count, fcn->exists,\n                  fcn->key[0], fcn->key[1], fcn->key[2], fcn->key[3]);\n        if (fcn->count == 0) {\n            ngx_http_file_cache_delete(cache, q, name);\n            wait = 0;\n        } else {\n            if (--tries) {\n                continue;\n            }\n            wait = 1;\n        }\n        break;\n    }\n    ngx_shmtx_unlock(&cache->shpool->mutex);\n    ngx_free(name);\n    return wait;\n}']