From: Alex Rousskov Date: Fri, 24 Feb 2012 22:29:40 +0000 (-0700) Subject: Ssl::ServerPeeker must become a store_client to prevent [error] entry trimming X-Git-Tag: BumpSslServerFirst.take05~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4ab7b43c6720a5fae6d730c8c34e6cec4cb3eea;p=thirdparty%2Fsquid.git Ssl::ServerPeeker must become a store_client to prevent [error] entry trimming 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. --- diff --git a/src/ssl/ServerPeeker.cc b/src/ssl/ServerPeeker.cc index b01a750e1d..ce490c9b0a 100644 --- a/src/ssl/ServerPeeker.cc +++ b/src/ssl/ServerPeeker.cc @@ -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 diff --git a/src/ssl/ServerPeeker.h b/src/ssl/ServerPeeker.h index 1e2849972a..9e44e9f77f 100644 --- a/src/ssl/ServerPeeker.h +++ b/src/ssl/ServerPeeker.h @@ -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); };