]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add ConnOpener to Comm namespace
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 18 Jul 2010 11:55:28 +0000 (23:55 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 18 Jul 2010 11:55:28 +0000 (23:55 +1200)
src/adaptation/icap/Xaction.cc
src/comm/ConnOpener.cc
src/comm/ConnOpener.h
src/dns_internal.cc
src/forward.cc
src/ftp.cc
src/ident/Ident.cc
src/neighbors.cc
src/tunnel.cc

index 660553603754eba8275a24cf35748956ba506640..c16782fe04fd63c77966d9500a7d72a44218045f 100644 (file)
@@ -129,7 +129,7 @@ void Adaptation::Icap::Xaction::openConnection()
     connector = asyncCall(93,3, "Adaptation::Icap::Xaction::noteCommConnected",
                           ConnectDialer(this, &Adaptation::Icap::Xaction::noteCommConnected));
 
-    ConnOpener *cs = new ConnOpener(connection, connector, TheConfig.connect_timeout(service().cfg().bypass));
+    Comm::ConnOpener *cs = new Comm::ConnOpener(connection, connector, TheConfig.connect_timeout(service().cfg().bypass));
     cs->setHost(s.cfg().host.termedBuf());
     AsyncJob::AsyncStart(cs);
 }
index 2efdbe7d88555f0c74427cabdc7afef457da8606..4a8f97eaa5aa9b7881d6ea8d6ab304fe15766c30 100644 (file)
 #include "icmp/net_db.h"
 #include "SquidTime.h"
 
-CBDATA_CLASS_INIT(ConnOpener);
+namespace Comm {
+    CBDATA_CLASS_INIT(ConnOpener);
+};
 
-ConnOpener::ConnOpener(Comm::ConnectionPointer &c, AsyncCall::Pointer &handler, time_t ctimeout) :
-        AsyncJob("ConnOpener"),
+Comm::ConnOpener::ConnOpener(Comm::ConnectionPointer &c, AsyncCall::Pointer &handler, time_t ctimeout) :
+        AsyncJob("Comm::ConnOpener"),
         connect_timeout(ctimeout),
         host(NULL),
         solo(c),
@@ -26,7 +28,7 @@ ConnOpener::ConnOpener(Comm::ConnectionPointer &c, AsyncCall::Pointer &handler,
     memset(&calls, 0, sizeof(calls));
 }
 
-ConnOpener::~ConnOpener()
+Comm::ConnOpener::~ConnOpener()
 {
     safe_free(host);
     solo = NULL;
@@ -35,34 +37,34 @@ ConnOpener::~ConnOpener()
 }
 
 bool
-ConnOpener::doneAll() const
+Comm::ConnOpener::doneAll() const
 {
     // is the conn to be opened still waiting?
     if (solo != NULL) {
-        debugs(5, 6, HERE << " ConnOpener::doneAll() ? NO. 'solo' is still set");
+        debugs(5, 6, HERE << " Comm::ConnOpener::doneAll() ? NO. 'solo' is still set");
         return false;
     }
 
     // is the callback still to be called?
     if (callback != NULL) {
-        debugs(5, 6, HERE << " ConnOpener::doneAll() ? NO. callback is still set");
+        debugs(5, 6, HERE << " Comm::ConnOpener::doneAll() ? NO. callback is still set");
         return false;
     }
 
-    debugs(5, 6, HERE << " ConnOpener::doneAll() ? YES.");
+    debugs(5, 6, HERE << " Comm::ConnOpener::doneAll() ? YES.");
     return true;
 }
 
 void
-ConnOpener::swanSong()
+Comm::ConnOpener::swanSong()
 {
     // cancel any event watchers
     if (calls.earlyabort != NULL) {
-        calls.earlyabort->cancel("ConnOpener::swanSong");
+        calls.earlyabort->cancel("Comm::ConnOpener::swanSong");
         calls.earlyabort = NULL;
     }
     if (calls.timeout != NULL) {
-        calls.timeout->cancel("ConnOpener::swanSong");
+        calls.timeout->cancel("Comm::ConnOpener::swanSong");
         calls.timeout = NULL;
     }
 
@@ -77,7 +79,7 @@ ConnOpener::swanSong()
 }
 
 void
-ConnOpener::setHost(const char * new_host)
+Comm::ConnOpener::setHost(const char * new_host)
 {
     // unset and erase if already set.
     if (host != NULL)
@@ -89,24 +91,24 @@ ConnOpener::setHost(const char * new_host)
 }
 
 const char *
-ConnOpener::getHost() const
+Comm::ConnOpener::getHost() const
 {
     return host;
 }
 
 void
-ConnOpener::callCallback(comm_err_t status, int xerrno)
+Comm::ConnOpener::callCallback(comm_err_t status, int xerrno)
 {
     /* remove handlers we don't want to happen anymore */
     if (solo != NULL && solo->fd > 0) {
         if (calls.earlyabort != NULL) {
             comm_remove_close_handler(solo->fd, calls.earlyabort);
-            calls.earlyabort->cancel("ConnOpener completed.");
+            calls.earlyabort->cancel("Comm::ConnOpener completed.");
             calls.earlyabort = NULL;
         }
         if (calls.timeout != NULL) {
             commSetTimeout(solo->fd, -1, NULL, NULL);
-            calls.timeout->cancel("ConnOpener completed.");
+            calls.timeout->cancel("Comm::ConnOpener completed.");
             calls.timeout = NULL;
         }
     }
@@ -128,7 +130,7 @@ ConnOpener::callCallback(comm_err_t status, int xerrno)
 }
 
 void
-ConnOpener::start()
+Comm::ConnOpener::start()
 {
     Must(solo != NULL);
 
@@ -147,16 +149,16 @@ ConnOpener::start()
         }
 
         if (calls.earlyabort == NULL) {
-            typedef CommCbMemFunT<ConnOpener, CommConnectCbParams> Dialer;
-            calls.earlyabort = asyncCall(5, 4, "ConnOpener::earlyAbort",
-                                         Dialer(this, &ConnOpener::earlyAbort));
+            typedef CommCbMemFunT<Comm::ConnOpener, CommConnectCbParams> Dialer;
+            calls.earlyabort = asyncCall(5, 4, "Comm::ConnOpener::earlyAbort",
+                                         Dialer(this, &Comm::ConnOpener::earlyAbort));
         }
         comm_add_close_handler(solo->fd, calls.earlyabort);
 
         if (calls.timeout == NULL) {
-            typedef CommCbMemFunT<ConnOpener, CommTimeoutCbParams> Dialer;
-            calls.timeout = asyncCall(5, 4, "ConnOpener::timeout",
-                                      Dialer(this, &ConnOpener::timeout));
+            typedef CommCbMemFunT<Comm::ConnOpener, CommTimeoutCbParams> Dialer;
+            calls.timeout = asyncCall(5, 4, "Comm::ConnOpener::timeout",
+                                      Dialer(this, &Comm::ConnOpener::timeout));
         }
         debugs(5, 3, HERE << "FD " << solo->fd << " timeout " << connect_timeout);
         commSetTimeout(solo->fd, connect_timeout, calls.timeout);
@@ -178,7 +180,7 @@ ConnOpener::start()
             return;
         } else {
             debugs(5, 5, HERE << "FD " << solo->fd << ": COMM_INPROGRESS");
-            commSetSelect(solo->fd, COMM_SELECT_WRITE, ConnOpener::ConnectRetry, this, 0);
+            commSetSelect(solo->fd, COMM_SELECT_WRITE, Comm::ConnOpener::ConnectRetry, this, 0);
         }
         break;
 
@@ -235,32 +237,32 @@ ConnOpener::start()
 }
 
 void
-ConnOpener::earlyAbort(const CommConnectCbParams &io)
+Comm::ConnOpener::earlyAbort(const CommConnectCbParams &io)
 {
     debugs(5, 3, HERE << "FD " << io.conn->fd);
     callCallback(COMM_ERR_CLOSING, io.xerrno); // NP: is closing or shutdown better?
 }
 
 void
-ConnOpener::connect(const CommConnectCbParams &unused)
+Comm::ConnOpener::connect(const CommConnectCbParams &unused)
 {
     start();
 }
 
 void
-ConnOpener::timeout(const CommTimeoutCbParams &unused)
+Comm::ConnOpener::timeout(const CommTimeoutCbParams &unused)
 {
     start();
 }
 
 void
-ConnOpener::ConnectRetry(int fd, void *data)
+Comm::ConnOpener::ConnectRetry(int fd, void *data)
 {
-    ConnOpener *cs = static_cast<ConnOpener *>(data);
+    ConnOpener *cs = static_cast<Comm::ConnOpener *>(data);
     cs->start();
 
-    // see if its done and delete ConnOpener? comm Writes are not yet a Job call.
+    // see if its done and delete Comm::ConnOpener? comm Writes are not yet a Job call.
     // so the automatic cleanup on call completion does not seem to happen
     if (cs->doneAll());
-        cs->deleteThis("Done after ConnOpener::ConnectRetry()");
+        cs->deleteThis("Done after Comm::ConnOpener::ConnectRetry()");
 }
index e287675414e77f4081ed7145a165bf0bcde030e9..9060728042589f8f642a80f80a2b18ab6041bba1 100644 (file)
@@ -8,6 +8,8 @@
 #include "comm/comm_err_t.h"
 #include "comm/forward.h"
 
+namespace Comm {
+
 /**
  * Async-opener of a Comm connection.
  */
@@ -89,4 +91,6 @@ private:
     CBDATA_CLASS2(ConnOpener);
 };
 
+}; // namespace Comm
+
 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */
index d62716d55320c3ca2eb2a286490fe4f1330d7e88..f20d643d856c8b4996c16d09316f053b604f7fa6 100644 (file)
@@ -749,7 +749,7 @@ idnsInitVC(int ns)
 
     AsyncCall::Pointer call = commCbCall(78,3, "idnsInitVCConnected", CommConnectCbPtrFun(idnsInitVCConnected, vc));
 
-    ConnOpener *cs = new ConnOpener(conn, call, Config.Timeout.connect);
+    Comm::ConnOpener *cs = new Comm::ConnOpener(conn, call, Config.Timeout.connect);
     cs->setHost("DNS TCP Socket");
     AsyncJob::AsyncStart(cs);
 }
index 0a727b2f1298297f1b2942505c5a3733536295ff..344982baa33d81eaf404562db247771a15dc8f7d 100644 (file)
@@ -80,7 +80,7 @@ FwdState::abort(void* d)
     FwdState* fwd = (FwdState*)d;
     Pointer tmp = fwd; // Grab a temporary pointer to keep the object alive during our scope.
 
-    if (fwd->paths.size() > 0 && fwd->paths[0]->fd > -1) {
+    if (fwd->paths.size() > 0 && fwd->paths[0]->isOpen()) {
         comm_remove_close_handler(fwd->paths[0]->fd, fwdServerClosedWrapper, fwd);
         fwd->paths[0]->close();
     }
@@ -171,7 +171,7 @@ FwdState::~FwdState()
 
     entry = NULL;
 
-    if (paths.size() > 0 && paths[0]->fd > -1) {
+    if (paths.size() > 0 && paths[0]->isOpen()) {
         comm_remove_close_handler(paths[0]->fd, fwdServerClosedWrapper, this);
         debugs(17, 3, HERE << "closing FD " << paths[0]->fd);
         paths[0]->close();
@@ -815,7 +815,7 @@ FwdState::connectStart()
 #endif
 
     AsyncCall::Pointer call = commCbCall(17,3, "fwdConnectDoneWrapper", CommConnectCbPtrFun(fwdConnectDoneWrapper, this));
-    ConnOpener *cs = new ConnOpener(paths[0], call, ctimeout);
+    Comm::ConnOpener *cs = new Comm::ConnOpener(paths[0], call, ctimeout);
     cs->setHost(host);
     AsyncJob::AsyncStart(cs);
 }
index bc6d563d99a265c5956c5d16e63986209bf597ea..f949ddeec1195ad71eeec0f908746e94dbed496c 100644 (file)
@@ -2418,7 +2418,7 @@ ftpReadEPSV(FtpStateData* ftpState)
     conn->fd = fd;
 
     AsyncCall::Pointer call = commCbCall(9,3, "FtpStateData::ftpPasvCallback", CommConnectCbPtrFun(FtpStateData::ftpPasvCallback, ftpState));
-    ConnOpener *cs = new ConnOpener(conn, call, Config.Timeout.connect);
+    Comm::ConnOpener *cs = new Comm::ConnOpener(conn, call, Config.Timeout.connect);
     cs->setHost(ftpState->data.host);
     AsyncJob::AsyncStart(cs);
 }
@@ -2702,7 +2702,7 @@ ftpReadPasv(FtpStateData * ftpState)
     conn->fd = ftpState->data.fd;
 
     AsyncCall::Pointer call = commCbCall(9,3, "FtpStateData::ftpPasvCallback", CommConnectCbPtrFun(FtpStateData::ftpPasvCallback, ftpState));
-    ConnOpener *cs = new ConnOpener(conn, call, Config.Timeout.connect);
+    Comm::ConnOpener *cs = new Comm::ConnOpener(conn, call, Config.Timeout.connect);
     cs->setHost(ftpState->data.host);
     AsyncJob::AsyncStart(cs);
 }
index bb20ef52d60c4c612590ab5221a1cd0f33ca983e..1955f182412bc0fd62c9b3e57338593c60b9e536 100644 (file)
@@ -250,7 +250,7 @@ Ident::Start(Comm::ConnectionPointer &conn, IDCB * callback, void *data)
     hash_join(ident_hash, &state->hash);
 
     AsyncCall::Pointer call = commCbCall(30,3, "Ident::ConnectDone", CommConnectCbPtrFun(Ident::ConnectDone, state));
-    AsyncJob::AsyncStart(new ConnOpener(state->conn, call, Ident::TheConfig.timeout));
+    AsyncJob::AsyncStart(new Comm::ConnOpener(state->conn, call, Ident::TheConfig.timeout));
 }
 
 void
index 28f104f8d4d5cc5c734df9695982ec771a6f5d6d..2558d536e810e463c78d30f164bf023eef0ec80f 100644 (file)
@@ -1369,7 +1369,7 @@ peerProbeConnect(peer * p)
         p->testing_now++;
 
         AsyncCall::Pointer call = commCbCall(15,3, "peerProbeConnectDone", CommConnectCbPtrFun(peerProbeConnectDone, p));
-        ConnOpener *cs = new ConnOpener(conn, call, ctimeout);
+        Comm::ConnOpener *cs = new Comm::ConnOpener(conn, call, ctimeout);
         cs->setHost(p->host);
         AsyncJob::AsyncStart(cs);
     }
index 79a8dc3124eb0d998a5e4914374f0775307a6abe..e69307e05047277000ab81e6d9e884c51068888c 100644 (file)
@@ -547,7 +547,7 @@ tunnelConnectDone(Comm::ConnectionPointer &conn, comm_err_t status, int xerrno,
         if (status != COMM_TIMEOUT && tunnelState->paths.size() > 0) {
             /* Try another IP of this destination host */
             AsyncCall::Pointer call = commCbCall(26,3, "tunnelConnectDone", CommConnectCbPtrFun(tunnelConnectDone, tunnelState));
-            ConnOpener *cs = new ConnOpener(tunnelState->paths[0], call, Config.Timeout.connect);
+            Comm::ConnOpener *cs = new Comm::ConnOpener(tunnelState->paths[0], call, Config.Timeout.connect);
             cs->setHost(tunnelState->url);
             AsyncJob::AsyncStart(cs);
         } else {
@@ -700,7 +700,7 @@ tunnelPeerSelectComplete(Comm::Paths *peer_paths, void *data)
     }
 
     AsyncCall::Pointer call = commCbCall(26,3, "tunnelConnectDone", CommConnectCbPtrFun(tunnelConnectDone, tunnelState));
-    ConnOpener *cs = new ConnOpener(tunnelState->paths[0], call, Config.Timeout.connect);
+    Comm::ConnOpener *cs = new Comm::ConnOpener(tunnelState->paths[0], call, Config.Timeout.connect);
     cs->setHost(tunnelState->url);
     AsyncJob::AsyncStart(cs);
 }