]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Roll Comm::Connection into new mgr/ code
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 26 Nov 2010 09:55:11 +0000 (22:55 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 26 Nov 2010 09:55:11 +0000 (22:55 +1300)
14 files changed:
src/mgr/ActionWriter.cc
src/mgr/ActionWriter.h
src/mgr/Filler.cc
src/mgr/Filler.h
src/mgr/Forwarder.cc
src/mgr/Forwarder.h
src/mgr/FunAction.cc
src/mgr/InfoAction.cc
src/mgr/Inquirer.cc
src/mgr/Inquirer.h
src/mgr/Request.cc
src/mgr/Request.h
src/mgr/StoreToCommWriter.cc
src/mgr/StoreToCommWriter.h

index de0557568ffa7da52b8bc97053f5796a95abe642..739471cadc9eb50d01c756f38673eb0a2a1e7db8 100644 (file)
@@ -7,17 +7,18 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "mgr/ActionWriter.h"
 #include "Store.h"
 
 
 CBDATA_NAMESPACED_CLASS_INIT(Mgr, ActionWriter);
 
-Mgr::ActionWriter::ActionWriter(const Action::Pointer &anAction, int aFd):
-        StoreToCommWriter(aFd, anAction->createStoreEntry()),
+Mgr::ActionWriter::ActionWriter(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn):
+        StoreToCommWriter(conn, anAction->createStoreEntry()),
         action(anAction)
 {
-    debugs(16, 5, HERE << "FD " << aFd << " action: " << action);
+    debugs(16, 5, HERE << conn << " action: " << action);
 }
 
 void
index 25a4bd204f82d690a8bfba0dc1082cb1f0370ab4..0180c44c85b7e7e68fba7dee79c8e057d782051d 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef SQUID_MGR_ACTION_WRITER_H
 #define SQUID_MGR_ACTION_WRITER_H
 
+#include "comm/forward.h"
 #include "HttpRequestMethod.h"
 #include "mgr/StoreToCommWriter.h"
 
@@ -20,7 +21,7 @@ namespace Mgr
 class ActionWriter: public StoreToCommWriter
 {
 public:
-    ActionWriter(const Action::Pointer &anAction, int aFd);
+    ActionWriter(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn);
 
 protected:
     /* AsyncJob API */
index a1afd6040464502f1088453fe8ad85c00ae5d342..83adae6175296f57ec6a7ed3d33bc11f93d51d56 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "mgr/Filler.h"
 #include "mgr/Response.h"
 #include "Store.h"
 
 CBDATA_NAMESPACED_CLASS_INIT(Mgr, Filler);
 
-Mgr::Filler::Filler(const Action::Pointer &anAction, int aFd,
+Mgr::Filler::Filler(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn,
                     unsigned int aRequestId):
-        StoreToCommWriter(aFd, anAction->createStoreEntry()),
+        StoreToCommWriter(conn, anAction->createStoreEntry()),
         action(anAction),
         requestId(aRequestId)
 {
-    debugs(16, 5, HERE << "FD " << aFd << " action: " << action);
+    debugs(16, 5, HERE << conn << " action: " << action);
 }
 
 void
index e6c7ba1f0382e0ed6f4b876aad0a65d5fe7d9cfc..1b5a9457623bbb698c208c4ff70108ae03172f4a 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef SQUID_MGR_FILLER_H
 #define SQUID_MGR_FILLER_H
 
+#include "comm/forward.h"
 #include "HttpRequestMethod.h"
 #include "mgr/Action.h"
 #include "mgr/StoreToCommWriter.h"
@@ -19,7 +20,7 @@ namespace Mgr
 class Filler: public StoreToCommWriter
 {
 public:
-    Filler(const Action::Pointer &anAction, int aFd, unsigned int aRequestId);
+    Filler(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn, unsigned int aRequestId);
 
 protected:
     /* AsyncJob API */
index 3d518d0212298371ad4819ce95d428c3a3523da8..480122a56bf806510bb24c5e069433366cb7a894 100644 (file)
@@ -8,6 +8,7 @@
 #include "config.h"
 #include "base/AsyncJobCalls.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "CommCalls.h"
 #include "errorpage.h"
 #include "HttpReply.h"
@@ -24,14 +25,14 @@ CBDATA_NAMESPACED_CLASS_INIT(Mgr, Forwarder);
 Mgr::Forwarder::RequestsMap Mgr::Forwarder::TheRequestsMap;
 unsigned int Mgr::Forwarder::LastRequestId = 0;
 
-Mgr::Forwarder::Forwarder(int aFd, const ActionParams &aParams,
+Mgr::Forwarder::Forwarder(const Comm::ConnectionPointer &conn, const ActionParams &aParams,
                           HttpRequest* aRequest, StoreEntry* anEntry):
         AsyncJob("Mgr::Forwarder"),
         params(aParams),
-        request(aRequest), entry(anEntry), fd(aFd), requestId(0), closer(NULL)
+        request(aRequest), entry(anEntry), clientConnection(conn), requestId(0), closer(NULL)
 {
-    debugs(16, 5, HERE << "FD " << aFd);
-    Must(fd >= 0);
+    debugs(16, 5, HERE << clientConnection);
+    Must(Comm::IsConnOpen(clientConnection));
     Must(request != NULL);
     Must(entry != NULL);
 
@@ -41,7 +42,7 @@ Mgr::Forwarder::Forwarder(int aFd, const ActionParams &aParams,
 
     closer = asyncCall(16, 5, "Mgr::Forwarder::noteCommClosed",
                        CommCbMemFunT<Forwarder, CommCloseCbParams>(this, &Forwarder::noteCommClosed));
-    comm_add_close_handler(fd, closer);
+    comm_add_close_handler(clientConnection->fd, closer);
 }
 
 Mgr::Forwarder::~Forwarder()
@@ -61,13 +62,12 @@ Mgr::Forwarder::~Forwarder()
 void
 Mgr::Forwarder::close()
 {
-    if (fd >= 0) {
+    if (Comm::IsConnOpen(clientConnection)) {
         if (closer != NULL) {
-            comm_remove_close_handler(fd, closer);
+            comm_remove_close_handler(clientConnection->fd, closer);
             closer = NULL;
         }
-        comm_close(fd);
-        fd = -1;
+        clientConnection->close();
     }
 }
 
@@ -84,7 +84,7 @@ Mgr::Forwarder::start()
         ++LastRequestId;
     requestId = LastRequestId;
     TheRequestsMap[requestId] = callback;
-    Request mgrRequest(KidIdentifier, requestId, fd, params);
+    Request mgrRequest(KidIdentifier, requestId, clientConnection, params);
     Ipc::TypedMsgHdr message;
 
     try {
@@ -126,8 +126,7 @@ void
 Mgr::Forwarder::noteCommClosed(const CommCloseCbParams& params)
 {
     debugs(16, 5, HERE);
-    Must(fd == params.fd);
-    fd = -1;
+    Must(!Comm::IsConnOpen(clientConnection));
     mustStop("commClosed");
 }
 
@@ -187,7 +186,7 @@ void
 Mgr::Forwarder::callException(const std::exception& e)
 {
     try {
-        if (entry != NULL && request != NULL && fd >= 0)
+        if (entry != NULL && request != NULL && Comm::IsConnOpen(clientConnection))
             quitOnError("exception", errorCon(ERR_INVALID_RESP, HTTP_INTERNAL_SERVER_ERROR, request));
     } catch (const std::exception& ex) {
         debugs(16, DBG_CRITICAL, HERE << ex.what());
@@ -235,6 +234,6 @@ void
 Mgr::Forwarder::Abort(void* param)
 {
     Forwarder* mgrFwdr = static_cast<Forwarder*>(param);
-    if (mgrFwdr->fd >= 0)
-        comm_close(mgrFwdr->fd);
+    if (Comm::IsConnOpen(mgrFwdr->clientConnection))
+        mgrFwdr->clientConnection->close();
 }
index 470a1a3fc7f42423a99e0b60385bba297051d7e4..f3cf15d87d5b67491cd6007709a53f4027ff3fef 100644 (file)
@@ -9,6 +9,7 @@
 #define SQUID_MGR_FORWARDER_H
 
 #include "base/AsyncJob.h"
+#include "comm/forward.h"
 #include "mgr/ActionParams.h"
 #include <map>
 
@@ -28,7 +29,7 @@ namespace Mgr
 class Forwarder: public AsyncJob
 {
 public:
-    Forwarder(int aFd, const ActionParams &aParams, HttpRequest* aRequest,
+    Forwarder(const Comm::ConnectionPointer &conn, const ActionParams &aParams, HttpRequest* aRequest,
               StoreEntry* anEntry);
     virtual ~Forwarder();
 
@@ -59,7 +60,7 @@ private:
     ActionParams params; ///< action parameters to pass to the other side
     HttpRequest* request; ///< HTTP client request for detailing errors
     StoreEntry* entry; ///< Store entry expecting the response
-    int fd; ///< HTTP client connection descriptor
+    Comm::ConnectionPointer clientConnection; ///< HTTP client connection descriptor
     unsigned int requestId; ///< request id
     AsyncCall::Pointer closer; ///< comm_close handler for the HTTP connection
 
index 4e7bc4927048114ce0ab4a5893bd5527076e1b65..05d1129ca336d1cf829623fb0636754cf15cc86d 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "mgr/Command.h"
 #include "mgr/Filler.h"
 #include "mgr/FunAction.h"
@@ -31,10 +32,10 @@ void
 Mgr::FunAction::respond(const Request& request)
 {
     debugs(16, 5, HERE);
-    const int fd = ImportHttpFdIntoComm(request.fd);
-    Must(fd >= 0);
+    const Comm::ConnectionPointer client = ImportHttpFdIntoComm(request.fd);
+    Must(Comm::IsConnOpen(client));
     Must(request.requestId != 0);
-    AsyncJob::Start(new Mgr::Filler(this, fd, request.requestId));
+    AsyncJob::Start(new Mgr::Filler(this, client, request.requestId));
 }
 
 void
index 27adf22ec872ce02a3fb6f78e9ab2df706c24c54..17ec7590cca05eef630b4210e49954a23f72279d 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "HttpReply.h"
 #include "ipc/Messages.h"
 #include "ipc/TypedMsgHdr.h"
@@ -155,10 +156,10 @@ void
 Mgr::InfoAction::respond(const Request& request)
 {
     debugs(16, 5, HERE);
-    int fd = ImportHttpFdIntoComm(request.fd);
-    Must(fd >= 0);
+    Comm::ConnectionPointer client = ImportHttpFdIntoComm(request.fd);
+    Must(Comm::IsConnOpen(client));
     Must(request.requestId != 0);
-    AsyncJob::Start(new Mgr::Filler(this, fd, request.requestId));
+    AsyncJob::Start(new Mgr::Filler(this, client, request.requestId));
 }
 
 void
index 3f9dc27e5ec5494493d1a91bcff1b8c90776e120..5da18137edd907c030c8393c3778160aa6653881 100644 (file)
@@ -7,7 +7,9 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm.h"
 #include "CommCalls.h"
+#include "comm/Connection.h"
 #include "HttpReply.h"
 #include "ipc/Coordinator.h"
 #include "mgr/ActionWriter.h"
@@ -32,23 +34,23 @@ LesserStrandByKidId(const Ipc::StrandCoord &c1, const Ipc::StrandCoord &c2)
     return c1.kidId < c2.kidId;
 }
 
-Mgr::Inquirer::Inquirer(Action::Pointer anAction, int aFd,
+Mgr::Inquirer::Inquirer(Action::Pointer anAction, const Comm::ConnectionPointer &conn,
                         const Request &aCause, const Ipc::StrandCoords &coords):
         AsyncJob("Mgr::Inquirer"),
         aggrAction(anAction),
         cause(aCause),
-        fd(aFd),
+        clientConnection(conn),
         strands(coords), pos(strands.begin()),
         requestId(0), closer(NULL), timeout(aggrAction->atomic() ? 10 : 100)
 {
-    debugs(16, 5, HERE << "FD " << aFd << " action: " << aggrAction);
+    debugs(16, 5, HERE << conn << " action: " << aggrAction);
 
     // order by ascending kid IDs; useful for non-aggregatable stats
     std::sort(strands.begin(), strands.end(), LesserStrandByKidId);
 
     closer = asyncCall(16, 5, "Mgr::Inquirer::noteCommClosed",
                        CommCbMemFunT<Inquirer, CommCloseCbParams>(this, &Inquirer::noteCommClosed));
-    comm_add_close_handler(fd, closer);
+    comm_add_close_handler(clientConnection->fd, closer);
 }
 
 Mgr::Inquirer::~Inquirer()
@@ -61,10 +63,9 @@ Mgr::Inquirer::~Inquirer()
 void
 Mgr::Inquirer::close()
 {
-    if (fd >= 0) {
+    if (Comm::IsConnOpen(clientConnection)) {
         removeCloseHandler();
-        comm_close(fd);
-        fd = -1;
+        clientConnection->close();
     }
 }
 
@@ -72,7 +73,7 @@ void
 Mgr::Inquirer::removeCloseHandler()
 {
     if (closer != NULL) {
-        comm_remove_close_handler(fd, closer);
+        comm_remove_close_handler(clientConnection->fd, closer);
         closer = NULL;
     }
 }
@@ -81,7 +82,7 @@ void
 Mgr::Inquirer::start()
 {
     debugs(16, 5, HERE);
-    Must(fd >= 0);
+    Must(Comm::IsConnOpen(clientConnection));
     Must(aggrAction != NULL);
 
     std::auto_ptr<HttpReply> reply(new HttpReply);
@@ -90,7 +91,7 @@ Mgr::Inquirer::start()
     std::auto_ptr<MemBuf> replyBuf(reply->pack());
     writer = asyncCall(16, 5, "Mgr::Inquirer::noteWroteHeader",
                        CommCbMemFunT<Inquirer, CommIoCbParams>(this, &Inquirer::noteWroteHeader));
-    comm_write_mbuf(fd, replyBuf.get(), writer);
+    comm_write_mbuf(clientConnection, replyBuf.get(), writer);
 }
 
 /// called when we wrote the response header
@@ -100,7 +101,7 @@ Mgr::Inquirer::noteWroteHeader(const CommIoCbParams& params)
     debugs(16, 5, HERE);
     writer = NULL;
     Must(params.flag == COMM_OK);
-    Must(params.fd == fd);
+    Must(clientConnection != NULL && params.fd == clientConnection->fd);
     Must(params.size != 0);
     // start inquiries at the initial pos
     inquire();
@@ -123,7 +124,7 @@ Mgr::Inquirer::inquire()
     const int kidId = pos->kidId;
     debugs(16, 4, HERE << "inquire kid: " << kidId << status());
     TheRequestsMap[requestId] = callback;
-    Request mgrRequest(KidIdentifier, requestId, fd,
+    Request mgrRequest(KidIdentifier, requestId, clientConnection,
                        aggrAction->command().params);
     Ipc::TypedMsgHdr message;
     mgrRequest.pack(message);
@@ -151,8 +152,8 @@ void
 Mgr::Inquirer::noteCommClosed(const CommCloseCbParams& params)
 {
     debugs(16, 5, HERE);
-    Must(fd < 0 || fd == params.fd);
-    fd = -1;
+    Must(!Comm::IsConnOpen(clientConnection) || clientConnection->fd == params.fd);
+    clientConnection = NULL; // AYJ: Do we actually have to NULL it?
     mustStop("commClosed");
 }
 
@@ -167,8 +168,8 @@ Mgr::Inquirer::swanSong()
     }
     if (aggrAction->aggregatable()) {
         removeCloseHandler();
-        AsyncJob::Start(new ActionWriter(aggrAction, fd));
-        fd = -1; // should not close fd because we passed it to ActionWriter
+        AsyncJob::Start(new ActionWriter(aggrAction, clientConnection));
+        clientConnection = NULL; // should not close fd because we passed it to ActionWriter
     }
     close();
 }
@@ -246,7 +247,7 @@ Mgr::Inquirer::status() const
 {
     static MemBuf buf;
     buf.reset();
-    buf.Printf(" [FD %d, requestId %u]", fd, requestId);
+    buf.Printf(" [FD %d, requestId %u]", clientConnection->fd, requestId);
     buf.terminate();
     return buf.content();
 }
index 7059daa2b3945a2c72e12e2b13dc9fc63f40a9c2..81087133271ffedc6e79f654cd5187d50db59ade 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "base/AsyncJobCalls.h"
 #include "base/AsyncJob.h"
+#include "comm/forward.h"
 #include "ipc/StrandCoords.h"
 #include "MemBuf.h"
 #include "mgr/Action.h"
@@ -27,7 +28,7 @@ namespace Mgr
 class Inquirer: public AsyncJob
 {
 public:
-    Inquirer(Action::Pointer anAction, int aFd, const Request &aCause,
+    Inquirer(Action::Pointer anAction, const Comm::ConnectionPointer &conn, const Request &aCause,
              const Ipc::StrandCoords &coords);
     virtual ~Inquirer();
 
@@ -63,7 +64,7 @@ private:
     Action::Pointer aggrAction; //< action to aggregate
 
     Request cause; ///< cache manager request received from HTTP client
-    int fd; ///< HTTP client socket descriptor
+    Comm::ConnectionPointer clientConnection; ///< HTTP client socket descriptor
 
     Ipc::StrandCoords strands; ///< all strands we want to query, in order
     Ipc::StrandCoords::const_iterator pos; ///< strand we should query now
index a0f4014cdd19b5f40040a56ed239624048cbb76b..045ea9b45a41b90572aeb61c7858593fa99c94fa 100644 (file)
@@ -7,15 +7,17 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "ipc/Messages.h"
 #include "mgr/ActionParams.h"
 #include "mgr/Request.h"
 
 
-Mgr::Request::Request(int aRequestorId, unsigned int aRequestId, int aFd,
+Mgr::Request::Request(int aRequestorId, unsigned int aRequestId, const Comm::ConnectionPointer &conn,
                       const ActionParams &aParams):
         requestorId(aRequestorId), requestId(aRequestId),
-        fd(aFd), params(aParams)
+        fd(conn->fd),
+        params(aParams)
 {
     Must(requestorId > 0);
     Must(requestId != 0);
index 89924f683713d666a4de190957ab4de0341d95ee..e85f37dcabf8b2d0a4a36240283d2b587fbb7852 100644 (file)
@@ -19,7 +19,7 @@ namespace Mgr
 class Request
 {
 public:
-    Request(int aRequestorId, unsigned int aRequestId, int aFd,
+    Request(int aRequestorId, unsigned int aRequestId, const Comm::ConnectionPointer &conn,
             const ActionParams &aParams);
 
     explicit Request(const Ipc::TypedMsgHdr& msg); ///< from recvmsg()
index 6eb3d22d75e80592d431fbb9632bcfa30f1cb7c9..b18f54eadc7cf98a92224f26b7ea268084abf7e9 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "config.h"
 #include "base/TextException.h"
+#include "comm/Connection.h"
 #include "CommCalls.h"
 #include "ipc/FdNotes.h"
 #include "mgr/StoreToCommWriter.h"
 CBDATA_NAMESPACED_CLASS_INIT(Mgr, StoreToCommWriter);
 
 
-Mgr::StoreToCommWriter::StoreToCommWriter(int aFd, StoreEntry* anEntry):
+Mgr::StoreToCommWriter::StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry* anEntry):
         AsyncJob("Mgr::StoreToCommWriter"),
-        fd(aFd), entry(anEntry), sc(NULL), writeOffset(0), closer(NULL)
+        clientConnection(conn), entry(anEntry), sc(NULL), writeOffset(0), closer(NULL)
 {
-    debugs(16, 6, HERE << "FD " << fd);
+    debugs(16, 6, HERE << clientConnection);
     closer = asyncCall(16, 5, "Mgr::StoreToCommWriter::noteCommClosed",
                        CommCbMemFunT<StoreToCommWriter, CommCloseCbParams>(this, &StoreToCommWriter::noteCommClosed));
-    comm_add_close_handler(fd, closer);
+    comm_add_close_handler(clientConnection->fd, closer);
 }
 
 Mgr::StoreToCommWriter::~StoreToCommWriter()
@@ -39,13 +40,12 @@ Mgr::StoreToCommWriter::~StoreToCommWriter()
 void
 Mgr::StoreToCommWriter::close()
 {
-    if (fd >= 0) {
+    if (Comm::IsConnOpen(clientConnection)) {
         if (closer != NULL) {
-            comm_remove_close_handler(fd, closer);
+            comm_remove_close_handler(clientConnection->fd, closer);
             closer = NULL;
         }
-        comm_close(fd);
-        fd = -1;
+        clientConnection->close();
     }
 }
 
@@ -53,7 +53,7 @@ void
 Mgr::StoreToCommWriter::start()
 {
     debugs(16, 6, HERE);
-    Must(fd >= 0);
+    Must(Comm::IsConnOpen(clientConnection));
     Must(entry != NULL);
     entry->registerAbort(&StoreToCommWriter::Abort, this);
     sc = storeClientListAdd(entry, this);
@@ -101,14 +101,14 @@ void
 Mgr::StoreToCommWriter::scheduleCommWrite(const StoreIOBuffer& ioBuf)
 {
     debugs(16, 6, HERE);
-    Must(fd >= 0);
+    Must(Comm::IsConnOpen(clientConnection));
     Must(ioBuf.data != NULL);
     // write filled buffer
     typedef CommCbMemFunT<StoreToCommWriter, CommIoCbParams> MyDialer;
     AsyncCall::Pointer writer =
         asyncCall(16, 5, "Mgr::StoreToCommWriter::noteCommWrote",
                   MyDialer(this, &StoreToCommWriter::noteCommWrote));
-    comm_write(fd, ioBuf.data, ioBuf.length, writer);
+    comm_write(clientConnection, ioBuf.data, ioBuf.length, writer);
 }
 
 void
@@ -116,7 +116,7 @@ Mgr::StoreToCommWriter::noteCommWrote(const CommIoCbParams& params)
 {
     debugs(16, 6, HERE);
     Must(params.flag == COMM_OK);
-    Must(params.fd == fd);
+    Must(clientConnection != NULL && params.fd == clientConnection->fd);
     Must(params.size != 0);
     writeOffset += params.size;
     if (!doneAll())
@@ -127,8 +127,7 @@ void
 Mgr::StoreToCommWriter::noteCommClosed(const CommCloseCbParams& params)
 {
     debugs(16, 6, HERE);
-    Must(fd == params.fd);
-    fd = -1;
+    Must(!Comm::IsConnOpen(clientConnection));
     mustStop("commClosed");
 }
 
@@ -160,28 +159,29 @@ void
 Mgr::StoreToCommWriter::Abort(void* param)
 {
     StoreToCommWriter* mgrWriter = static_cast<StoreToCommWriter*>(param);
-    if (mgrWriter->fd >= 0)
-        comm_close(mgrWriter->fd);
+    if (Comm::IsConnOpen(mgrWriter->clientConnection))
+        mgrWriter->clientConnection->close();
 }
 
-
-int
+Comm::ConnectionPointer
 Mgr::ImportHttpFdIntoComm(int fd)
 {
+    Comm::ConnectionPointer result = new Comm::Connection();
     struct sockaddr_in addr;
     socklen_t len = sizeof(addr);
     if (getsockname(fd, reinterpret_cast<sockaddr*>(&addr), &len) == 0) {
-        Ip::Address ipAddr(addr);
+        result->fd = fd;
+        result->local = addr;
         struct addrinfo* addr_info = NULL;
-        ipAddr.GetAddrInfo(addr_info);
+        result->local.GetAddrInfo(addr_info);
         addr_info->ai_socktype = SOCK_STREAM;
         addr_info->ai_protocol = IPPROTO_TCP;
-        comm_import_opened(fd, ipAddr, COMM_NONBLOCKING, Ipc::FdNote(Ipc::fdnHttpSocket), addr_info);
-        ipAddr.FreeAddrInfo(addr_info);
+        comm_import_opened(result, Ipc::FdNote(Ipc::fdnHttpSocket), addr_info);
+        result->local.FreeAddrInfo(addr_info);
     } else {
         debugs(16, DBG_CRITICAL, HERE << "ERROR: FD " << fd << ' ' << xstrerror());
         ::close(fd);
         fd = -1;
     }
-    return fd;
+    return result;
 }
index 116ffdba51dceeec9daacbb32f89ffa3606ff03b..9369f4cbede614f3095128e3bfef026ee0d0614f 100644 (file)
@@ -9,6 +9,7 @@
 #define SQUID_MGR_STORE_TO_COMM_WRITER_H
 
 #include "base/AsyncJob.h"
+#include "comm/forward.h"
 #include "mgr/Action.h"
 #include "StoreIOBuffer.h"
 
@@ -25,7 +26,7 @@ namespace Mgr
 class StoreToCommWriter: public AsyncJob
 {
 public:
-    StoreToCommWriter(int aFd, StoreEntry *anEntry);
+    StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry *anEntry);
     virtual ~StoreToCommWriter();
 
 protected:
@@ -53,7 +54,7 @@ protected:
     void close();
 
 protected:
-    int fd; ///< HTTP client descriptor
+    Comm::ConnectionPointer clientConnection; ///< HTTP client descriptor
 
     StoreEntry* entry; ///< store entry with the cache manager response
     store_client* sc; ///< our registration with the store
@@ -66,7 +67,7 @@ protected:
 };
 
 /// import HTTP socket fd from another strand into our Comm state
-extern int ImportHttpFdIntoComm(int fd);
+extern Comm::ConnectionPointer ImportHttpFdIntoComm(int fd);
 
 } // namespace Mgr