Bug report: missing SCARCE string in nginx-1.1.15/src/http/ngx_http_file_cache.c

Hello,

the value of the NGX_HTTP_CACHE_SCARCE cache status is defined in
nginx-1.1.15/src/http/ngx_http_cache.h, but unlike the other cache
status strings, it’s missing from
nginx-1.1.15/src/http/ngx_http_file_cache.c.

The function ngx_http_upstream_cache_status() in
nginx-1.1.15/src/http/ngx_http_upstream.c references the status
strings directly as ngx_http_cache_status[n].len, so with the
SCARCE cache status string missing, this is a segmentation violation
waiting to happen.

Here’s the patch to fix the problem:

--- src/http/ngx_http_file_cache.c.orig 2012-02-16 00:18:21.000000000 -0800 +++ src/http/ngx_http_file_cache.c 2012-02-16 00:25:00.000000000 -0800 @@ -53,7 +53,8 @@ ngx_string("EXPIRED"), ngx_string("STALE"), ngx_string("UPDATING"), - ngx_string("HIT") + ngx_string("HIT"), + ngx_string("SCARCE") }; ---

Max

Hello!

On Thu, Feb 16, 2012 at 01:08:58PM +0400, Max wrote:

SCARCE cache status string missing, this is a segmentation violation
ngx_string(“UPDATING”),

  • ngx_string(“HIT”)
  • ngx_string(“HIT”),
  • ngx_string(“SCARCE”)
    };

The NGX_HTTP_CACHE_SCARCE value can’t appear in u->cache_status,
and hence there is no real problem. It’s a special value used by
cache to inform upstream that there is no cached response (i.e.
MISS cache status) and cacheing should be enabled due to min_uses
preventing it.

Maxim D.

16 февраля 2012, 14:08 от Maxim D. [email protected]:

waiting to happen.

  • ngx_string(“HIT”)
  • ngx_string(“HIT”),
  • ngx_string(“SCARCE”)
    };

The NGX_HTTP_CACHE_SCARCE value can’t appear in u->cache_status,
and hence there is no real problem. It’s a special value used by
cache to inform upstream that there is no cached response (i.e.
MISS cache status) and cacheing should be enabled due to min_uses
preventing it.

You mean DISABLED due to file cache node exists being 0 or min_uses
being set too high?

nginx-1.1.15/src/http/ngx_http_upstream.c:

652 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t
*u)
653 {

719 rc = ngx_http_file_cache_open®;

742 switch (rc) {

774 case NGX_HTTP_CACHE_SCARCE:
775
776 u->cacheable = 0;
777
778 break;

795 }
800 }

Max

Hello!

On Fri, Feb 17, 2012 at 12:43:39PM +0400, Max wrote:

strings directly as ngx_http_cache_status[n].len, so with the
ngx_string(“STALE”),
MISS cache status) and cacheing should be enabled due to min_uses
preventing it.

You mean DISABLED due to file cache node exists being 0 or min_uses
being set too high?

Yep, s/should/should not/.

Maxim D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs