]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Ssl::ServerPeeker must become a store_client to prevent [error] entry trimming
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 24 Feb 2012 22:29:40 +0000 (15:29 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 24 Feb 2012 22:29:40 +0000 (15:29 -0700)
We do not need a store client during the certificate peeking stage because we
do not send the error to the client and only accumulate what is being written
to the store. However, if there is no store client then Store will trim the
entry and we will hit a

  store_client.cc:198: "entry->swap_filen > -1 || entry->swappingOut()"

assertion when we finally try to use it to serve the error response.

src/ssl/ServerPeeker.cc
src/ssl/ServerPeeker.h

index b01a750e1dbc61255d5c2041251276e1c0f34814..ce490c9b0a6fcb8beb90cd9cba4579aaa3a9c422 100644 (file)
@@ -21,7 +21,9 @@ Ssl::ServerPeeker::ServerPeeker(ConnStateData *anInitiator,
     AsyncJob("Ssl::ServerPeeker"),
     initiator(anInitiator),
     clientConnection(anInitiator->clientConnection),
-    request(new HttpRequest)
+    request(new HttpRequest),
+    entry(NULL),
+    sc(NULL)
 {
     debugs(33, 4, HERE << "will peek at " << host << ':' << port);
     request->flags.sslPeek = 1;
@@ -31,12 +33,18 @@ Ssl::ServerPeeker::ServerPeeker(ConnStateData *anInitiator,
     request->clientConnectionManager = initiator;
     const char *uri = urlCanonical(request);
     entry = storeCreateEntry(uri, uri, request->flags, request->method);
+    // We do not need to be a client because the error contents will be used
+    // later, but an entry without any client will trim all its contents away.
+    sc = storeClientListAdd(entry, this);
 }
 
 Ssl::ServerPeeker::~ServerPeeker()
 {
-    if (entry)
+    if (entry) {
+        debugs(33, 4, HERE << "stopped peeking via " << *entry);
+        storeUnregister(sc, entry, this);
         entry->unlock();
+    }
 }
 
 void
index 1e2849972ae0eab32285e9f95a2254884ad3260f..9e44e9f77f1b55a29312ae6fb1fe7a98dc9e2db7 100644 (file)
@@ -50,6 +50,7 @@ private:
     HttpRequest::Pointer request;
 
     StoreEntry *entry; ///< for receiving Squid-generated error messages
+    store_client *sc; ///< dummy client to prevent entry trimming
 
     CBDATA_CLASS2(ServerPeeker);
 };