From ad05b958fa522d73023eebf37dbfbf57829a9507 Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Wed, 11 May 2022 16:51:10 +0000 Subject: [PATCH] Ensure initClient MasterXactions have listening ports (#993) MasterXaction creation code that forgets to supply a port for an initClient transaction will now be rejected by the compiler. This safety improvement hit two problems described below. The TcpAcceptor class was incorrectly creating a MasterXaction object for FTP DATA connections. We moved MasterXaction creation to TcpAcceptor callbacks because only they know whether accepting a TCP connection implies a new master transaction start (it does not for FTP DATA cases). The Downloader class was implemented to spawn its own MasterXaction using XactionInitiator info supplied by the download requestor. That design is incompatible with the new static assertion because each MasterXaction creator must now hard-code XactionInitiator value for the assertion to work at _compile_ time. All other contexts naturally hard-code that value. We saw two ways to resolve this conflict: a) Let the download requestor create the MasterXaction object for the Downloader. The primary advantage of this (implemented) approach is that it allows (future) client request processing code to satisfy client requests using Downloader. Such request satisfaction requires sharing the master transaction between the client transaction and the downloader transaction, and this change enables such sharing. This change moves the "Which master transaction does this download belong to?" question from the Downloader into download requestors. b) Move initClient-has-port enforcement (and squidPort) from MasterXaction into XactionInitiator. The primary advantage of this (not implemented) approach is that it places that enforcement inside the type it is meant to police (essentially) -- XactionInitiator. The two changes are complementary. We did not implement (b) because it requires significant XactionInitiator redesign, moving _all_ originating client information from MasterXaction to XactionInitiator (currently squidPort and tcpClient). --- src/CommCalls.cc | 6 +++--- src/CommCalls.h | 4 ++-- src/Downloader.cc | 7 +++---- src/Downloader.h | 8 ++++---- src/MasterXaction.h | 22 +++++++++++++++++++++- src/PeerPoolMgr.cc | 2 +- src/acl/Asn.cc | 2 +- src/adaptation/ecap/Host.cc | 2 +- src/adaptation/icap/Xaction.cc | 2 +- src/client_side.cc | 21 +++++++++++++-------- src/client_side_reply.cc | 3 ++- src/comm/TcpAcceptor.cc | 5 ++--- src/esi/Include.cc | 2 +- src/htcp.cc | 2 +- src/icmp/net_db.cc | 2 +- src/icp_v2.cc | 2 +- src/mgr/Inquirer.cc | 2 +- src/mime.cc | 2 +- src/neighbors.cc | 2 +- src/peer_digest.cc | 2 +- src/security/PeerConnector.cc | 4 +++- src/servers/FtpServer.cc | 11 +++++++---- src/servers/Http1Server.cc | 6 +++--- src/servers/forward.h | 4 ++-- src/store_digest.cc | 2 +- src/tests/testHttpRequest.cc | 6 +++--- 26 files changed, 81 insertions(+), 52 deletions(-) diff --git a/src/CommCalls.cc b/src/CommCalls.cc index 7933a50d47..519219bd12 100644 --- a/src/CommCalls.cc +++ b/src/CommCalls.cc @@ -49,7 +49,7 @@ CommCommonCbParams::print(std::ostream &os) const /* CommAcceptCbParams */ CommAcceptCbParams::CommAcceptCbParams(void *aData): - CommCommonCbParams(aData), xaction() + CommCommonCbParams(aData) { } @@ -61,8 +61,8 @@ CommAcceptCbParams::print(std::ostream &os) const { CommCommonCbParams::print(os); - if (xaction != NULL) - os << ", " << xaction->id; + if (port && port->listenConn) + os << ", " << port->listenConn->codeContextGist(); } /* CommConnectCbParams */ diff --git a/src/CommCalls.h b/src/CommCalls.h index c2adfcf34b..e56a79196f 100644 --- a/src/CommCalls.h +++ b/src/CommCalls.h @@ -101,8 +101,8 @@ public: void print(std::ostream &os) const; - /// Transaction which this call is part of. - MasterXaction::Pointer xaction; + /// the configuration listening port this call relates to (may be nil) + AnyP::PortCfgPointer port; }; // connect parameters diff --git a/src/Downloader.cc b/src/Downloader.cc index b7f8553e6b..c1295e0476 100644 --- a/src/Downloader.cc +++ b/src/Downloader.cc @@ -64,12 +64,12 @@ Downloader::CbDialer::print(std::ostream &os) const os << " Http Status:" << status << Raw("body data", object.rawContent(), 64).hex(); } -Downloader::Downloader(SBuf &url, AsyncCall::Pointer &aCallback, const XactionInitiator initiator, unsigned int level): +Downloader::Downloader(const SBuf &url, const AsyncCall::Pointer &aCallback, const MasterXactionPointer &masterXaction, unsigned int level): AsyncJob("Downloader"), url_(url), callback_(aCallback), level_(level), - initiator_(initiator) + masterXaction_(masterXaction) { } @@ -133,8 +133,7 @@ Downloader::buildRequest() { const HttpRequestMethod method = Http::METHOD_GET; - const MasterXaction::Pointer mx = new MasterXaction(initiator_); - auto * const request = HttpRequest::FromUrl(url_, mx, method); + const auto request = HttpRequest::FromUrl(url_, masterXaction_, method); if (!request) { debugs(33, 5, "Invalid URI: " << url_); return false; //earlyError(...) diff --git a/src/Downloader.h b/src/Downloader.h index 3dd24d2cc1..957afdc21f 100644 --- a/src/Downloader.h +++ b/src/Downloader.h @@ -14,13 +14,14 @@ #include "http/forward.h" #include "http/StatusCode.h" #include "sbuf/SBuf.h" -#include "XactionInitiator.h" class ClientHttpRequest; class StoreIOBuffer; class clientStreamNode; class DownloaderContext; typedef RefCount DownloaderContextPointer; +class MasterXaction; +using MasterXactionPointer = RefCount; /// The Downloader class fetches SBuf-storable things for other Squid /// components/transactions using internal requests. For example, it is used @@ -46,7 +47,7 @@ public: Http::StatusCode status; }; - Downloader(SBuf &url, AsyncCall::Pointer &aCallback, const XactionInitiator initiator, unsigned int level = 0); + Downloader(const SBuf &url, const AsyncCall::Pointer &aCallback, const MasterXactionPointer &, unsigned int level = 0); virtual ~Downloader(); virtual void swanSong(); @@ -76,8 +77,7 @@ private: AsyncCall::Pointer callback_; ///< callback to call when download finishes SBuf object_; ///< the object body data const unsigned int level_; ///< holds the nested downloads level - /// The initiator of the download request. - XactionInitiator initiator_; + MasterXactionPointer masterXaction_; ///< download transaction context /// Pointer to an object that stores the clientStream required info DownloaderContextPointer context_; diff --git a/src/MasterXaction.h b/src/MasterXaction.h index 277a1b8b97..9dcc8ecb7e 100644 --- a/src/MasterXaction.h +++ b/src/MasterXaction.h @@ -41,7 +41,20 @@ class MasterXaction : public RefCountable public: typedef RefCount Pointer; - explicit MasterXaction(const XactionInitiator anInitiator) : initiator(anInitiator) {}; + /// Create a master transaction not associated with a AnyP::PortCfg port. + template + static Pointer MakePortless() + { + static_assert(anInitiator != XactionInitiator::initClient, "not an HTTP or FTP client"); + return new MasterXaction(anInitiator, nullptr); + } + + /// Create a master transaction associated with a AnyP::PortCfg port. + /// \param aPort may be nil if port information was lost + static Pointer MakePortful(const AnyP::PortCfgPointer &aPort) + { + return new MasterXaction(XactionInitiator::initClient, aPort); + } /// transaction ID. InstanceId id; @@ -59,6 +72,13 @@ public: bool generatingConnect = false; // TODO: add state from other Jobs in the transaction + +private: + // use public Make() functions instead + MasterXaction(const XactionInitiator anInitiator, const AnyP::PortCfgPointer &aPort): + squidPort(aPort), + initiator(anInitiator) + {} }; #endif /* SQUID_SRC_MASTERXACTION_H */ diff --git a/src/PeerPoolMgr.cc b/src/PeerPoolMgr.cc index 60d7343f40..974f7a0648 100644 --- a/src/PeerPoolMgr.cc +++ b/src/PeerPoolMgr.cc @@ -58,7 +58,7 @@ PeerPoolMgr::start() { AsyncJob::start(); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initPeerPool); + const auto mx = MasterXaction::MakePortless(); // ErrorState, getOutgoingAddress(), and other APIs may require a request. // We fake one. TODO: Optionally send this request to peers? request = new HttpRequest(Http::METHOD_OPTIONS, AnyP::PROTO_HTTP, "http", "*", mx); diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index f0719671c8..5f2372e716 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -237,7 +237,7 @@ asnCacheStart(int as) debugs(53, 3, "AS " << as); ASState *asState = new ASState; asState->as_number = as; - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initAsn); + const auto mx = MasterXaction::MakePortless(); asState->request = new HttpRequest(mx); asState->request->url = whoisUrl; asState->request->method = Http::METHOD_GET; diff --git a/src/adaptation/ecap/Host.cc b/src/adaptation/ecap/Host.cc index edb55de0b3..6202a5f14d 100644 --- a/src/adaptation/ecap/Host.cc +++ b/src/adaptation/ecap/Host.cc @@ -163,7 +163,7 @@ Adaptation::Ecap::Host::closeDebug(std::ostream *debug) Adaptation::Ecap::Host::MessagePtr Adaptation::Ecap::Host::newRequest() const { - static const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initAdaptationOrphan_); + static const auto mx = MasterXaction::MakePortless(); return MessagePtr(new Adaptation::Ecap::MessageRep(new HttpRequest(mx))); } diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index 499c618dd0..33d2dc9eda 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -94,7 +94,7 @@ Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Icap::Serv { debugs(93,3, typeName << " constructed, this=" << this << " [icapx" << id << ']'); // we should not call virtual status() here - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initAdaptation); + const auto mx = MasterXaction::MakePortless(); icapRequest = new HttpRequest(mx); HTTPMSGLOCK(icapRequest); icap_tr_start = current_time; diff --git a/src/client_side.cc b/src/client_side.cc index a1c683e6d0..f85594fe51 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -2299,22 +2299,24 @@ ConnStateData::acceptTls() void httpAccept(const CommAcceptCbParams ¶ms) { - MasterXaction::Pointer xact = params.xaction; - AnyP::PortCfgPointer s = xact->squidPort; + Assure(params.port); // NP: it is possible the port was reconfigured when the call or accept() was queued. if (params.flag != Comm::OK) { // Its possible the call was still queued when the client disconnected - debugs(33, 2, s->listenConn << ": accept failure: " << xstrerr(params.xerrno)); + debugs(33, 2, params.port->listenConn << ": accept failure: " << xstrerr(params.xerrno)); return; } debugs(33, 4, params.conn << ": accepted"); fd_note(params.conn->fd, "client http connect"); + const auto xact = MasterXaction::MakePortful(params.port); + xact->tcpClient = params.conn; // Socket is ready, setup the connection manager to start using it auto *srv = Http::NewServer(xact); + // XXX: do not abandon the MasterXaction object AsyncJob::Start(srv); // usually async-calls readSomeData() } @@ -2499,22 +2501,25 @@ httpsSslBumpAccessCheckDone(Acl::Answer answer, void *data) static void httpsAccept(const CommAcceptCbParams ¶ms) { - MasterXaction::Pointer xact = params.xaction; - const AnyP::PortCfgPointer s = xact->squidPort; + Assure(params.port); // NP: it is possible the port was reconfigured when the call or accept() was queued. if (params.flag != Comm::OK) { // Its possible the call was still queued when the client disconnected - debugs(33, 2, "httpsAccept: " << s->listenConn << ": accept failure: " << xstrerr(params.xerrno)); + debugs(33, 2, "httpsAccept: " << params.port->listenConn << ": accept failure: " << xstrerr(params.xerrno)); return; } + const auto xact = MasterXaction::MakePortful(params.port); + xact->tcpClient = params.conn; + debugs(33, 4, params.conn << " accepted, starting SSL negotiation."); fd_note(params.conn->fd, "client https connect"); // Socket is ready, setup the connection manager to start using it auto *srv = Https::NewServer(xact); + // XXX: do not abandon the MasterXaction object AsyncJob::Start(srv); // usually async-calls postHttpsAccept() } @@ -2530,7 +2535,7 @@ ConnStateData::postHttpsAccept() return; } - MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortful(port); mx->tcpClient = clientConnection; // Create a fake HTTP request and ALE for the ssl_bump ACL check, // using tproxy/intercept provided destination IP and port. @@ -3236,7 +3241,7 @@ ConnStateData::buildFakeRequest(SBuf &useHost, unsigned short usePort, const SBu extendLifetime(); stream->registerWithConn(); - MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortful(port); mx->tcpClient = clientConnection; // Setup Http::Request object. Maybe should be replaced by a call to (modified) // clientProcessRequest diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index ca6334ac8e..dc293c556d 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -2139,7 +2139,8 @@ clientReplyContext::createStoreEntry(const HttpRequestMethod& m, RequestFlags re */ if (http->request == NULL) { - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto connManager = http->getConn(); + const auto mx = MasterXaction::MakePortful(connManager ? connManager->port : nullptr); // XXX: These fake URI parameters shadow the real (or error:...) URI. // TODO: Either always set the request earlier and assert here OR use // http->uri (converted to Anyp::Uri) to create this catch-all request. diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index b93991ef8b..134e10f525 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -322,10 +322,9 @@ Comm::TcpAcceptor::notify(const Comm::Flag flag, const Comm::ConnectionPointer & if (theCallSub != NULL) { AsyncCall::Pointer call = theCallSub->callback(); CommAcceptCbParams ¶ms = GetCommParams(call); - params.xaction = new MasterXaction(XactionInitiator::initClient); - params.xaction->squidPort = listenPort_; + params.port = listenPort_; params.fd = conn->fd; - params.conn = params.xaction->tcpClient = newConnDetails; + params.conn = newConnDetails; params.flag = flag; params.xerrno = errcode; ScheduleCallHere(call); diff --git a/src/esi/Include.cc b/src/esi/Include.cc index 1dc93481e9..9c2f28af3a 100644 --- a/src/esi/Include.cc +++ b/src/esi/Include.cc @@ -287,7 +287,7 @@ ESIInclude::Start (ESIStreamContext::Pointer stream, char const *url, ESIVarStat char const *tempUrl = vars->extractChar (); debugs(86, 5, "ESIIncludeStart: Starting subrequest with url '" << tempUrl << "'"); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initEsi); + const auto mx = MasterXaction::MakePortless(); if (clientBeginRequest(Http::METHOD_GET, tempUrl, esiBufferRecipient, esiBufferDetach, stream.getRaw(), &tempheaders, stream->localbuffer->buf, HTTP_REQBUF_SZ, mx)) { debugs(86, DBG_CRITICAL, "ERROR: starting new ESI subrequest failed"); } diff --git a/src/htcp.cc b/src/htcp.cc index c1eef39122..391b620562 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -701,7 +701,7 @@ htcpUnpackSpecifier(char *buf, int sz) // Parse the request method.HttpRequestMethodXXX(s->method); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initHtcp); + const auto mx = MasterXaction::MakePortless(); s->request = HttpRequest::FromUrlXXX(s->uri, mx, method == Http::METHOD_NONE ? HttpRequestMethod(Http::METHOD_GET) : method); if (!s->request) { debugs(31, 3, "failed to create request. Invalid URI?"); diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index 52a5fa2cba..a5da2f7808 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -1296,7 +1296,7 @@ netdbExchangeStart(void *data) static const SBuf netDB("netdb"); char *uri = internalRemoteUri(p->secure.encryptTransport, p->host, p->http_port, "/squid-internal-dynamic/", netDB); debugs(38, 3, "Requesting '" << uri << "'"); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initIcmp); + const auto mx = MasterXaction::MakePortless(); HttpRequestPointer req(HttpRequest::FromUrlXXX(uri, mx)); if (!req) { diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 5d6d639e9b..740b6ec7ca 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -461,7 +461,7 @@ icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from) return NULL; } - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initIcp); + const auto mx = MasterXaction::MakePortless(); auto *result = HttpRequest::FromUrlXXX(url, mx); if (!result) icpCreateAndSend(ICP_ERR, 0, url, reqnum, 0, fd, from, nullptr); diff --git a/src/mgr/Inquirer.cc b/src/mgr/Inquirer.cc index 6a2d610fc1..45fdf1afa5 100644 --- a/src/mgr/Inquirer.cc +++ b/src/mgr/Inquirer.cc @@ -76,7 +76,7 @@ Mgr::Inquirer::start() std::unique_ptr replyBuf; if (strands.empty()) { const char *url = aggrAction->command().params.httpUri.termedBuf(); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initIpc); + const auto mx = MasterXaction::MakePortless(); auto *req = HttpRequest::FromUrlXXX(url, mx); ErrorState err(ERR_INVALID_URL, Http::scNotFound, req, nullptr); std::unique_ptr reply(err.BuildHttpReply()); diff --git a/src/mime.cc b/src/mime.cc index 83da9fba00..5db0c46281 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -400,7 +400,7 @@ MimeIcon::load() /* fill `e` with a canned 2xx response object */ - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initIcon); + const auto mx = MasterXaction::MakePortless(); HttpRequestPointer r(HttpRequest::FromUrlXXX(url_, mx)); if (!r) fatalf("mimeLoadIcon: cannot parse internal URL: %s", url_); diff --git a/src/neighbors.cc b/src/neighbors.cc index acc97465ff..64c6c4d022 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1418,7 +1418,7 @@ peerCountMcastPeersCreateAndSend(CachePeer * const p) snprintf(url, MAX_URL, "http://"); p->in_addr.toUrl(url+7, MAX_URL -8 ); strcat(url, "/"); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initPeerMcast); + const auto mx = MasterXaction::MakePortless(); auto *req = HttpRequest::FromUrlXXX(url, mx); assert(req != nullptr); const AccessLogEntry::Pointer ale = new AccessLogEntry; diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 4bbb95fb63..ebae875930 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -306,7 +306,7 @@ peerDigestRequest(PeerDigest * pd) url = xstrdup(internalRemoteUri(p->secure.encryptTransport, p->host, p->http_port, "/squid-internal-periodic/", SBuf(StoreDigestFileName))); debugs(72, 2, url); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initCacheDigest); + const auto mx = MasterXaction::MakePortless(); req = HttpRequest::FromUrlXXX(url, mx); assert(req); diff --git a/src/security/PeerConnector.cc b/src/security/PeerConnector.cc index 7e96485fc7..cfebd9a94d 100644 --- a/src/security/PeerConnector.cc +++ b/src/security/PeerConnector.cc @@ -639,7 +639,9 @@ Security::PeerConnector::startCertDownloading(SBuf &url) "Security::PeerConnector::certDownloadingDone", PeerConnectorCertDownloaderDialer(&Security::PeerConnector::certDownloadingDone, this)); - const auto dl = new Downloader(url, certCallback, XactionInitiator::initCertFetcher, certDownloadNestingLevel() + 1); + const auto dl = new Downloader(url, certCallback, + MasterXaction::MakePortless(), + certDownloadNestingLevel() + 1); certDownloadWait.start(dl, certCallback); } diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index 472b8b242d..7068bfd6fa 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -241,21 +241,24 @@ Ftp::Server::noteBodyConsumerAborted(BodyPipe::Pointer ptr) void Ftp::Server::AcceptCtrlConnection(const CommAcceptCbParams ¶ms) { - MasterXaction::Pointer xact = params.xaction; - AnyP::PortCfgPointer s = xact->squidPort; + Assure(params.port); // NP: it is possible the port was reconfigured when the call or accept() was queued. if (params.flag != Comm::OK) { // Its possible the call was still queued when the client disconnected - debugs(33, 2, s->listenConn << ": FTP accept failure: " << xstrerr(params.xerrno)); + debugs(33, 2, params.port->listenConn << ": FTP accept failure: " << xstrerr(params.xerrno)); return; } debugs(33, 4, params.conn << ": accepted"); fd_note(params.conn->fd, "client ftp connect"); + const auto xact = MasterXaction::MakePortful(params.port); + xact->tcpClient = params.conn; + AsyncJob::Start(new Server(xact)); + // XXX: do not abandon the MasterXaction object } void @@ -720,7 +723,7 @@ Ftp::Server::parseOneRequest() const SBuf *path = (params.length() && CommandHasPathParameter(cmd)) ? ¶ms : NULL; calcUri(path); - MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortful(port); mx->tcpClient = clientConnection; auto * const request = HttpRequest::FromUrl(uri, mx, method); if (!request) { diff --git a/src/servers/Http1Server.cc b/src/servers/Http1Server.cc index 9b6e56f83c..38599df0be 100644 --- a/src/servers/Http1Server.cc +++ b/src/servers/Http1Server.cc @@ -133,7 +133,7 @@ Http::One::Server::buildHttpRequest(Http::StreamPointer &context) } // TODO: move URL parse into Http Parser and INVALID_URL into the above parse error handling - MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortful(port); mx->tcpClient = clientConnection; request = HttpRequest::FromUrlXXX(http->uri, mx, parser_->method()); if (!request) { @@ -392,13 +392,13 @@ Http::One::Server::noteTakeServerConnectionControl(ServerConnectionContext serve } ConnStateData * -Http::NewServer(MasterXactionPointer &xact) +Http::NewServer(const MasterXaction::Pointer &xact) { return new Http1::Server(xact, false); } ConnStateData * -Https::NewServer(MasterXactionPointer &xact) +Https::NewServer(const MasterXaction::Pointer &xact) { return new Http1::Server(xact, true); } diff --git a/src/servers/forward.h b/src/servers/forward.h index 4cdbe85f57..d3ca715fc7 100644 --- a/src/servers/forward.h +++ b/src/servers/forward.h @@ -24,7 +24,7 @@ class Server; } // namespace One /// create a new HTTP connection handler; never returns NULL -ConnStateData *NewServer(MasterXactionPointer &xact); +ConnStateData *NewServer(const MasterXaction::Pointer &xact); } // namespace Http @@ -32,7 +32,7 @@ namespace Https { /// create a new HTTPS connection handler; never returns NULL -ConnStateData *NewServer(MasterXactionPointer &xact); +ConnStateData *NewServer(const MasterXaction::Pointer &xact); } // namespace Https diff --git a/src/store_digest.cc b/src/store_digest.cc index e15197cde2..a7c20e0888 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -417,7 +417,7 @@ storeDigestRewriteStart(void *) debugs(71, 2, "storeDigestRewrite: start rewrite #" << sd_state.rewrite_count + 1); const char *url = internalLocalUri("/squid-internal-periodic/", SBuf(StoreDigestFileName)); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initCacheDigest); + const auto mx = MasterXaction::MakePortless(); auto req = HttpRequest::FromUrlXXX(url, mx); RequestFlags flags; diff --git a/src/tests/testHttpRequest.cc b/src/tests/testHttpRequest.cc index 047296858c..38d1a0b0df 100644 --- a/src/tests/testHttpRequest.cc +++ b/src/tests/testHttpRequest.cc @@ -46,7 +46,7 @@ testHttpRequest::testCreateFromUrl() /* vanilla url, implicit method */ unsigned short expected_port; SBuf url("http://foo:90/bar"); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortless(); HttpRequest *aRequest = HttpRequest::FromUrl(url, mx); expected_port = 90; CPPUNIT_ASSERT(aRequest != nullptr); @@ -109,7 +109,7 @@ testHttpRequest::testIPv6HostColonBug() /* valid IPv6 address without port */ SBuf url("http://[2000:800::45]/foo"); - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortless(); aRequest = HttpRequest::FromUrl(url, mx, Http::METHOD_GET); expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->url.port()); @@ -143,7 +143,7 @@ void testHttpRequest::testSanityCheckStartLine() { MemBuf input; - const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initClient); + const auto mx = MasterXaction::MakePortless(); PrivateHttpRequest engine(mx); Http::StatusCode error = Http::scNone; size_t hdr_len; -- 2.47.2