------------------------------------------------------------ revno: 13212 revision-id: squid3@treenet.co.nz-20140105194923-e91revckyxnxiyxr parent: squid3@treenet.co.nz-20140108042904-4o3ap1i1y096zxmb committer: Amos Jeffries branch nick: trunk timestamp: Sun 2014-01-05 11:49:23 -0800 message: Cleanup: remove ClientSocketContextNew() wrapper function This wrapper function for the ClientSocketContext default constructor is better performed as an explicit parametered constructor which prevents accidental use of the default constructor leading to invalid state after creation (a context always requires connectino and parent pointers). ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140105194923-e91revckyxnxiyxr # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: e372a3eba72b2969e8983ef4de61a9bb9759e443 # timestamp: 2014-01-08 09:55:19 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140108042904-\ # 4o3ap1i1y096zxmb # # Begin patch === modified file 'src/client_side.cc' --- src/client_side.cc 2013-12-06 23:52:26 +0000 +++ src/client_side.cc 2014-01-05 19:49:23 +0000 @@ -194,9 +194,6 @@ CBDATA_CLASS_INIT(ClientSocketContext); /* Local functions */ -/* ClientSocketContext */ -static ClientSocketContext *ClientSocketContextNew(const Comm::ConnectionPointer &clientConn, ClientHttpRequest *); -/* other */ static IOCB clientWriteComplete; static IOCB clientWriteBodyComplete; static IOACB httpAccept; @@ -337,11 +334,16 @@ clientStreamDetach(getTail(), http); } -ClientSocketContext::ClientSocketContext() : http(NULL), reply(NULL), next(NULL), +ClientSocketContext::ClientSocketContext(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq) : + clientConnection(aConn), + http(aReq), + reply(NULL), + next(NULL), writtenToSocket(0), mayUseConnection_ (false), connRegistered_ (false) { + assert(http != NULL); memset (reqbuf, '\0', sizeof (reqbuf)); flags.deferred = 0; flags.parsed_ok = 0; @@ -349,17 +351,6 @@ deferredparams.rep = NULL; } -ClientSocketContext * -ClientSocketContextNew(const Comm::ConnectionPointer &client, ClientHttpRequest * http) -{ - ClientSocketContext *newContext; - assert(http != NULL); - newContext = new ClientSocketContext; - newContext->http = http; - newContext->clientConnection = client; - return newContext; -} - void ClientSocketContext::writeControlMsg(HttpControlMsg &msg) { @@ -1979,7 +1970,7 @@ http->req_sz = csd->in.notYetUsed; http->uri = xstrdup(uri); setLogUri (http, uri); - context = ClientSocketContextNew(csd->clientConnection, http); + context = new ClientSocketContext(csd->clientConnection, http); tempBuffer.data = context->reqbuf; tempBuffer.length = HTTP_REQBUF_SZ; clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach, @@ -2320,7 +2311,7 @@ http = new ClientHttpRequest(csd); http->req_sz = HttpParserRequestLen(hp); - result = ClientSocketContextNew(csd->clientConnection, http); + result = new ClientSocketContext(csd->clientConnection, http); tempBuffer.data = result->reqbuf; tempBuffer.length = HTTP_REQBUF_SZ; === modified file 'src/client_side.h' --- src/client_side.h 2013-08-22 18:39:41 +0000 +++ src/client_side.h 2014-01-05 19:49:23 +0000 @@ -83,7 +83,7 @@ public: typedef RefCount Pointer; - ClientSocketContext(); + ClientSocketContext(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq); ~ClientSocketContext(); bool startOfOutput() const; void writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag); === modified file 'src/tests/stub_client_side.cc' --- src/tests/stub_client_side.cc 2013-06-27 15:58:46 +0000 +++ src/tests/stub_client_side.cc 2014-01-05 19:49:23 +0000 @@ -4,8 +4,8 @@ #define STUB_API "client_side.cc" #include "tests/STUB.h" -ClientSocketContext::ClientSocketContext() STUB -ClientSocketContext::~ClientSocketContext() STUB +//ClientSocketContext::ClientSocketContext(const ConnectionPointer&, ClientHttpRequest*) STUB +//ClientSocketContext::~ClientSocketContext() STUB bool ClientSocketContext::startOfOutput() const STUB_RETVAL(false) void ClientSocketContext::writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag) STUB void ClientSocketContext::keepaliveNextRequest() STUB