]> git.pld-linux.org Git - packages/squid.git/commitdiff
- fix issues with caching responses with "Vary" responses auto/th/squid-3.2.3-3
authorJan Rękorajski <baggins@pld-linux.org>
Mon, 29 Oct 2012 14:51:30 +0000 (15:51 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Mon, 29 Oct 2012 14:51:30 +0000 (15:51 +0100)
- rel 3

squid.spec
squidv3-vary-cache-1.patch [new file with mode: 0644]
squidv3-vary-headers-shm-hack.patch [new file with mode: 0644]

index c0b2ca396e51e9bb48c8f1c11a80dcec94a7d5e3..a05f76466a3e8973196f1329f0cdd9e277df2df8 100644 (file)
@@ -17,7 +17,7 @@ Summary(uk.UTF-8):    Squid - кеш об'єктів Internet
 Summary(zh_CN.UTF-8):  SQUID 高速缓冲代理服务器
 Name:          squid
 Version:       3.2.3
-Release:       2
+Release:       3
 Epoch:         7
 License:       GPL v2
 Group:         Networking/Daemons
@@ -38,6 +38,11 @@ Patch2:              %{name}-crash-on-ENOSPC.patch
 Patch4:                %{name}-2.5.STABLE4-apache-like-combined-log.patch
 Patch5:                %{name}-ppc-m32.patch
 Patch6:                %{name}-cachemgr-webapp.patch
+# http://www.squid-cache.org/mail-archive/squid-dev/201207/0099.html
+# http://www.squid-cache.org/mail-archive/squid-dev/201207/att-0177/squidv3-vary-cache-1.patch
+Patch7:                squidv3-vary-cache-1.patch
+# http://www.squid-cache.org/mail-archive/squid-dev/201207/att-0177/squidv3-vary-headers-shm-hack.patch
+Patch8:                squidv3-vary-headers-shm-hack.patch
 URL:           http://www.squid-cache.org/
 BuildRequires: autoconf
 BuildRequires: automake
@@ -584,6 +589,8 @@ Ten pakiet zawiera skrypty perlowe i dodatkowe programy dla Squida.
 %patch5 -p1
 %endif
 %patch6 -p1
+%patch7 -p1
+%patch8 -p1
 
 %build
 %{__libtoolize}
diff --git a/squidv3-vary-cache-1.patch b/squidv3-vary-cache-1.patch
new file mode 100644 (file)
index 0000000..7f7c592
--- /dev/null
@@ -0,0 +1,20 @@
+diff -uNrw squid-3.2.0.18/src/store.cc squid-3.2.0.18.n/src/store.cc
+--- squid-3.2.0.18/src/store.cc        2012-07-11 06:06:31.000000000 +0400
++++ squid-3.2.0.18.n/src/store.cc      2012-07-17 18:50:22.746674120 +0400
+@@ -769,12 +769,14 @@
+             }
+ #endif
+-            pe->replaceHttpReply(rep);
++            pe->replaceHttpReply(rep, false);
+             pe->timestampsSet();
+             pe->makePublic();
++            pe->startWriting();
++
+             pe->complete();
+             pe->unlock();
+
diff --git a/squidv3-vary-headers-shm-hack.patch b/squidv3-vary-headers-shm-hack.patch
new file mode 100644 (file)
index 0000000..f292328
--- /dev/null
@@ -0,0 +1,122 @@
+diff -uNrw squid-3.2.0.18/src/client_side.cc squid-3.2.0.18/src/client_side.cc
+--- squid-3.2.0.18/src/client_side.cc  2012-07-18 19:36:09.982711673 +0400
++++ squid-3.2.0.18/src/client_side.cc  2012-07-18 19:47:28.594672449 +0400
+@@ -1349,6 +1349,15 @@
+ {
+     reply = rep;
++    /* Remove our HDR_X_VARY_FOR hack if present.
++     * Client won't get the joke anyway.
++     */
++    if (rep && rep->header.has(HDR_X_VARY_FOR))
++    {
++        debugs(11,3, HERE << "HDR_X_VARY_FOR hack detected. Cleaning it up");
++        rep->header.delById(HDR_X_VARY_FOR);
++    }
++
+     if (http->request->range)
+         buildRangeHeader(rep);
+ }
+diff -uNrw squid-3.2.0.18/src/http.cc squid-3.2.0.18/src/http.cc
+--- squid-3.2.0.18/src/http.cc 2012-07-18 19:36:09.962712057 +0400
++++ squid-3.2.0.18/src/http.cc 2012-07-18 19:40:02.442715425 +0400
+@@ -880,6 +880,12 @@
+         }
+         entry->mem_obj->vary_headers = xstrdup(vary);
++        /* XXX: Currently we are losing vary_headers when
++         * saving objects to shm, so we now add them as header
++         * and remove on preparing client reply.
++         */
++        debugs(11,3,"haveParsedReplyHeaders: inserting HDR_X_VARY_FOR into the reply");
++        rep->header.putStr(HDR_X_VARY_FOR, entry->mem_obj->vary_headers);
+     }
+     /*
+diff -uNrw squid-3.2.0.18/src/HttpHeader.cc squid-3.2.0.18/src/HttpHeader.cc
+--- squid-3.2.0.18/src/HttpHeader.cc   2012-07-18 19:36:09.982711673 +0400
++++ squid-3.2.0.18/src/HttpHeader.cc   2012-07-18 19:52:20.551796245 +0400
+@@ -147,6 +147,7 @@
+     {"X-Cache", HDR_X_CACHE, ftStr},
+     {"X-Cache-Lookup", HDR_X_CACHE_LOOKUP, ftStr},
+     {"X-Forwarded-For", HDR_X_FORWARDED_FOR, ftStr},
++    {"X-Vary-For", HDR_X_VARY_FOR, ftStr},
+     {"X-Request-URI", HDR_X_REQUEST_URI, ftStr},
+     {"X-Squid-Error", HDR_X_SQUID_ERROR, ftStr},
+ #if X_ACCELERATOR_VARY
+@@ -206,7 +207,8 @@
+ #endif
+     HDR_SURROGATE_CAPABILITY,
+     HDR_SURROGATE_CONTROL,
+-    HDR_X_FORWARDED_FOR
++    HDR_X_FORWARDED_FOR,
++    HDR_X_VARY_FOR
+ };
+ /* general-headers */
+diff -uNrw squid-3.2.0.18/src/HttpHeader.h squid-3.2.0.18/src/HttpHeader.h
+--- squid-3.2.0.18/src/HttpHeader.h    2012-07-18 19:36:09.978711678 +0400
++++ squid-3.2.0.18/src/HttpHeader.h    2012-07-18 19:36:44.754628494 +0400
+@@ -136,6 +136,7 @@
+     HDR_AUTHENTICATION_INFO,            /**< RFC 2617 */
+     HDR_X_CACHE,                        /**< Squid custom header */
+     HDR_X_CACHE_LOOKUP,                       /**< Squid custom header. temporary hack that became de-facto. TODO remove */
++    HDR_X_VARY_FOR,                       /**< Squid custom header. temporary hack */
+     HDR_X_FORWARDED_FOR,                /**< Squid custom header */
+     HDR_X_REQUEST_URI,                  /**< Squid custom header appended if ADD_X_REQUEST_URI is defined */
+     HDR_X_SQUID_ERROR,                  /**< Squid custom header on generated error responses */
+diff -uNrw squid-3.2.0.18/src/MemObject.cc squid-3.2.0.18/src/MemObject.cc
+--- squid-3.2.0.18/src/MemObject.cc    2012-07-18 19:36:09.986711701 +0400
++++ squid-3.2.0.18/src/MemObject.cc    2012-07-18 19:43:45.843879163 +0400
+@@ -189,6 +189,24 @@
+     return _reply;
+ }
++/* Dirty hack to fill vary_headers field from
++ * our special HDR_X_VARY_FOR reply header
++ */
++void
++MemObject::fillVaryHeader()
++{
++    if (_reply && _reply->header.has(HDR_X_VARY_FOR))
++    {
++        debugs(20,3, HERE << "got HDR_X_VARY_FOR: " << _reply->header.getList(HDR_X_VARY_FOR));
++        if (! vary_headers)
++                      vary_headers = xstrdup(_reply->header.getList(HDR_X_VARY_FOR).termedBuf());
++              else
++                      debugs(20,3, HERE << "vary_headers has already been set up: " << vary_headers);
++      }
++    else
++        debugs(20,3, HERE << "no HDR_X_VARY_FOR present!");
++}
++
+ void
+ MemObject::replaceHttpReply(HttpReply *newrep)
+ {
+diff -uNrw squid-3.2.0.18/src/MemObject.h squid-3.2.0.18/src/MemObject.h
+--- squid-3.2.0.18/src/MemObject.h     2012-07-18 20:06:23.151879182 +0400
++++ squid-3.2.0.18/src/MemObject.h     2012-07-18 20:08:14.755379555 +0400
+@@ -76,6 +76,8 @@
+     int64_t lowestMemReaderOffset() const;
+     bool readAheadPolicyCanRead() const;
+     void addClient(store_client *);
++    /* dirty hack to recover vary_headers from the reply */
++    void fillVaryHeader();
+     /* XXX belongs in MemObject::swapout, once swaphdrsz is managed
+      * better
+      */
+diff -uNrw squid-3.2.0.18/src/store.cc squid-3.2.0.18/src/store.cc
+--- squid-3.2.0.18/src/store.cc        2012-07-18 19:36:09.958711514 +0400
++++ squid-3.2.0.18/src/store.cc        2012-07-18 19:55:00.518734384 +0400
+@@ -1689,6 +1689,10 @@
+         mem_obj = hidden_mem_obj;
+         hidden_mem_obj = NULL;
+         mem_obj->resetUrls(aUrl, aLogUrl);
++        /* XXX: we're probably restoring from the cache,
++         * so try to recover vary_headers in mem_obj
++         */
++        mem_obj->fillVaryHeader();
+         return;
+     }
+
This page took 0.094847 seconds and 4 git commands to generate.