# Bug report: missing SCARCE string in nginx-1.1.15/src/http/ngx\_http\_file\_cache.c

**URL:** <https://www.ruby-forum.com/t/bug-report-missing-scarce-string-in-nginx-1-1-15-src-http-ngx-http-file-cache-c/216875>\
**Category:** NGINX\
**Created:** [February 16, 2012, 10:09am UTC](https://www.ruby-forum.com/t/bug-report-missing-scarce-string-in-nginx-1-1-15-src-http-ngx-http-file-cache-c/216875 "2012-02-16T10:09:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 16, 2012, 10:09am UTC](https://www.ruby-forum.com/t/bug-report-missing-scarce-string-in-nginx-1-1-15-src-http-ngx-http-file-cache-c/216875/1 "2012-02-16T10:09:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 16, 2012, 11:08am UTC](https://www.ruby-forum.com/t/bug-report-missing-scarce-string-in-nginx-1-1-15-src-http-ngx-http-file-cache-c/216875/2 "2012-02-16T11:08:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 17, 2012, 9:44am UTC](https://www.ruby-forum.com/t/bug-report-missing-scarce-string-in-nginx-1-1-15-src-http-ngx-http-file-cache-c/216875/3 "2012-02-17T09:44:25Z")

</div>

16 февраля 2012, 14:08 от Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > 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(r);  
…  
742 switch (rc) {  
…  
774 case NGX\_HTTP\_CACHE\_SCARCE:  
775  
776 u-\>cacheable = 0;  
777  
778 break;  
…  
795 }  
800 }

Max

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [February 17, 2012, 12:23pm UTC](https://www.ruby-forum.com/t/bug-report-missing-scarce-string-in-nginx-1-1-15-src-http-ngx-http-file-cache-c/216875/4 "2012-02-17T12:23:44Z")

</div>

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.
