squid-1878

Version:

2.6.STABLE8

Bug link:

http://bugs.squid-cache.org/show_bug.cgi?id=1878

Symptom (Failure):
When the request header contains:  “If-Modified-Since”, Squid always return 304 (Not-Modified) on modified webpage as long as the web page was cached.

How it is diagnosed:

We reproduced the failure!

Just run Squid and send the customized header using telnet!

Root Cause:

The logic in Squid in handling “If-Modified-Since” is completely wrong. It sets “is_modified” variable value to 0 (indicating content not modified) when the content was actually modified, causing Squid to return 304 when it shouldn’t.

--- src/client_side.c        21 Jan 2007 10:26:44 -0000        1.693.2.1

+++ src/client_side.c        24 Jan 2007 01:31:10 -0000
@@ -2237,12 +2237,12 @@ clientCacheHit(void *data, char *buf, ss

 

 /* r->flags.ims indicates “if-modified-since” was present in the request header. */

 if (r->flags.ims) {

    …

         /* Once fall here (request header contains if-modified-since), then it will always result in failure, since the logic below is completely bogus! */

        if (modifiedSince(e, http->request)) {

      // when modifiedSince returns 1, it means the content was actually modified! But the original logic, set ‘is_modified’ to 0, when it should have set it to 1.

      /* This branch decision is simply not tested! */

-            debug(33, 4) ("clientCacheHit: If-Modified-Since not modified\n");

-            is_modified = 0;

-        } else {

            debug(33, 4) ("clientCacheHit: If-Modified-Since modified\n");

+            is_modified = 1;

+        } else {

+            debug(33, 4) ("clientCacheHit: If-Modified-Since not modified\n");

            if (is_modified == -1)

-                is_modified = 1;

+                is_modified = 0;

        }

    }

}

 if (stale) {

   if (is_modified == 0) {    

           // Not modified! Generating 304 result!

             MemBuf mb = httpPacked304Reply(e->mem_obj->reply);

           … …

           storeAppend(e, mb.buf, mb.size);

           memBufClean(&mb);

           storeComplete(e);  

           return;

   }

}

   }

Is there any log message?:

No.

Can developers anticipate the error?

No. It is very hard to anticipate an error message! Cuz the symptom can be completely normal.

Can Errlog print an error msg?

Yes. If use Errlog-AG to log the untested branch decisions, we can put a log msg:

        if (modifiedSince(e, http->request)) {

Since this branch decision is not tested.