]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: remove ClientSocketContextNew() wrapper function
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Jan 2014 19:49:23 +0000 (11:49 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Jan 2014 19:49:23 +0000 (11:49 -0800)
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).

src/client_side.cc
src/client_side.h
src/tests/stub_client_side.cc

index a68280d58425d8978254f3598bbb45c361247f0b..b5a00a35273a77575407ea661b43957228eecf21 100644 (file)
@@ -194,9 +194,6 @@ static void clientListenerConnectionOpened(AnyP::PortCfg *s, const Ipc::FdNoteId
 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 @@ ClientSocketContext::connIsFinished()
     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 @@ ClientSocketContext::ClientSocketContext() : http(NULL), reply(NULL), next(NULL)
     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 @@ parseHttpRequestAbort(ConnStateData * csd, const char *uri)
     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 @@ parseHttpRequest(ConnStateData *csd, HttpParser *hp, HttpRequestMethod * method_
     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;
 
index ec95d11cc5874050c3c51a0cf7322635715867df..ddb3d52325439c1bd403fd8a96d8402ce2ca460a 100644 (file)
@@ -83,7 +83,7 @@ class ClientSocketContext : public RefCountable
 
 public:
     typedef RefCount<ClientSocketContext> 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);
index 77d9ff469277edb519b67e4a86645b8305845448..2a167e0feefc2ffbda8c7e8d01e4a869e7292cd3 100644 (file)
@@ -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