From b4ab7b43c6720a5fae6d730c8c34e6cec4cb3eea Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Fri, 24 Feb 2012 15:29:40 -0700 Subject: [PATCH] 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. --- src/ssl/ServerPeeker.cc | 12 ++++++++++-- src/ssl/ServerPeeker.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) 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); }; -- 2.47.2