]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceLayout: shuffle comm IO loops into libcomm and Comm namespace
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 10 Jan 2011 09:43:43 +0000 (02:43 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 10 Jan 2011 09:43:43 +0000 (02:43 -0700)
31 files changed:
src/DiskIO/DiskDaemon/DiskdIOStrategy.cc
src/Makefile.am
src/client_side.cc
src/comm.cc
src/comm.h
src/comm/IoCallback.cc
src/comm/ListenStateData.cc
src/comm/Loops.h [new file with mode: 0644]
src/comm/Makefile.am
src/comm/ModDevPoll.cc [moved from src/comm_devpoll.cc with 96% similarity]
src/comm/ModEpoll.cc [moved from src/comm_epoll.cc with 86% similarity]
src/comm/ModKqueue.cc [moved from src/comm_kqueue.cc with 97% similarity]
src/comm/ModPoll.cc [moved from src/comm_poll.cc with 98% similarity]
src/comm/ModSelect.cc [moved from src/comm_select.cc with 97% similarity]
src/comm/ModSelectWin32.cc [moved from src/comm_select_win32.cc with 98% similarity]
src/comm_epoll.h [deleted file]
src/comm_kqueue.h [deleted file]
src/comm_select.h [deleted file]
src/disk.cc
src/dns_internal.cc
src/fd.cc
src/forward.cc
src/htcp.cc
src/icmp/IcmpSquid.cc
src/icp_v2.cc
src/log/ModDaemon.cc
src/main.cc
src/snmp_core.cc
src/tests/stub_comm.cc
src/wccp.cc
src/wccp2.cc

index f143bd827794b93c9936ce4efae1b556b4d63343..6d054e3056c9a21876538dd5168fd091566e6352 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "comm/Loops.h"
 
 #include <sys/ipc.h>
 #include <sys/msg.h>
@@ -203,10 +204,8 @@ DiskdIOStrategy::init()
     fd_note(wfd, "squid -> diskd");
 
     commSetTimeout(wfd, -1, NULL, NULL);
-
     commSetNonBlocking(wfd);
-
-    comm_quick_poll_required();
+    Comm::QuickPollRequired();
 }
 
 /*
index 1d7345666cdac6896d2eed72826a2603adf93531..dc061644c354578e479828af8b316c2d4bc32842 100644 (file)
@@ -236,19 +236,6 @@ DiskIO/DiskIOModules_gen.cc: Makefile
        $(SHELL) $(srcdir)/DiskIO/modules.sh $(DISK_MODULES) > DiskIO/DiskIOModules_gen.cc
 
 
-squid_COMMSOURCES = \
-       comm_select.cc \
-       comm_select.h \
-       comm_select_win32.cc \
-       comm_poll.cc \
-       comm_poll.h \
-       comm_devpoll.cc \
-       comm_epoll.cc \
-       comm_epoll.h \
-       comm_kqueue.cc \
-       comm_kqueue.h
-
-
 # common library for all the binaries and tests. This is kindof a catch all
 # and smaller libraries split from this are encouraged. Using lt convenience
 # libraries, dependencies should not be a problem either.
@@ -295,7 +282,6 @@ squid_SOURCES = \
        CommIO.h \
        CompletionDispatcher.cc \
        CompletionDispatcher.h \
-       $(squid_COMMSOURCES) \
        CommRead.h \
        ConfigOption.cc \
        ConfigParser.cc \
@@ -1170,7 +1156,6 @@ tests_testCacheManager_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
-       $(squid_COMMSOURCES) \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -1373,7 +1358,6 @@ tests_testEvent_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
-       $(squid_COMMSOURCES) \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -1534,7 +1518,6 @@ tests_testEventLoop_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
-       $(squid_COMMSOURCES) \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -1682,7 +1665,6 @@ tests_test_http_range_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
-       $(squid_COMMSOURCES) \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -1850,7 +1832,6 @@ tests_testHttpRequest_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
-       $(squid_COMMSOURCES) \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
@@ -2266,7 +2247,6 @@ tests_testURL_SOURCES = \
        client_side_request.cc \
        ClientInfo.h \
        clientStream.cc \
-       $(squid_COMMSOURCES) \
        ConfigOption.cc \
        ConfigParser.cc \
        CpuAffinityMap.cc \
index f9c3960e800e2dd74cc9cfc9f9525d867922976c..d961801a5f8e8eaf8253b2f8f2a62fe51dae3f62 100644 (file)
 
 #include "acl/FilledChecklist.h"
 #include "auth/UserRequest.h"
+#include "base/TextException.h"
 #include "ChunkedCodingParser.h"
 #include "client_side.h"
 #include "client_side_reply.h"
 #include "client_side_request.h"
+#if USE_DELAY_POOLS
+#include "ClientInfo.h"
+#endif
 #include "ClientRequestContext.h"
 #include "clientStream.h"
 #include "comm.h"
 #include "comm/Write.h"
 #include "comm/ListenStateData.h"
-#include "base/TextException.h"
+#include "comm/Loops.h"
 #include "ConnectionDetail.h"
 #include "eui/Config.h"
 #include "fde.h"
 #include "ProtoPort.h"
 #include "rfc1738.h"
 #include "SquidTime.h"
-#include "Store.h"
-
-#if USE_DELAY_POOLS
-#include "ClientInfo.h"
-#endif
-
 #if USE_SSL
 #include "ssl/context_storage.h"
 #include "ssl/helper.h"
 #include "ssl/crtd_message.h"
 #include "ssl/certificate_db.h"
 #endif
+#include "Store.h"
 
 #if HAVE_LIMITS
 #include <limits>
@@ -3045,7 +3044,7 @@ ConnStateData::requestTimeout(const CommTimeoutCbParams &io)
         /*
          * Aha, but we don't want a read handler!
          */
-        commSetSelect(io.fd, COMM_SELECT_READ, NULL, NULL, 0);
+        Comm::SetSelect(io.fd, COMM_SELECT_READ, NULL, NULL, 0);
     }
 
 #else
@@ -3262,11 +3261,11 @@ clientNegotiateSSL(int fd, void *data)
         switch (ssl_error) {
 
         case SSL_ERROR_WANT_READ:
-            commSetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, conn, 0);
+            Comm::SetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, conn, 0);
             return;
 
         case SSL_ERROR_WANT_WRITE:
-            commSetSelect(fd, COMM_SELECT_WRITE, clientNegotiateSSL, conn, 0);
+            Comm::SetSelect(fd, COMM_SELECT_WRITE, clientNegotiateSSL, conn, 0);
             return;
 
         case SSL_ERROR_SYSCALL:
@@ -3415,7 +3414,7 @@ httpsAccept(int sock, int newfd, ConnectionDetail *details,
         commSetTcpKeepalive(newfd, s->http.tcp_keepalive.idle, s->http.tcp_keepalive.interval, s->http.tcp_keepalive.timeout);
     }
 
-    commSetSelect(newfd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0);
+    Comm::SetSelect(newfd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0);
 
     clientdbEstablished(details->peer, 1);
 
@@ -3532,10 +3531,8 @@ ConnStateData::getSslContextDone(SSL_CTX * sslContext, bool isNew)
     // commSetTimeout() was called for this request before we switched.
 
     // Disable the client read handler until peer selection is complete
-    commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
-
-    commSetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, this, 0);
-
+    Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, this, 0);
     switchedToHttps_ = true;
     return true;
 }
index cc78e490fcd1b50591fbacdef1184bdf878770b0..ad28dd1cea94ea50d9ebc03b2d2628c06828fd0d 100644 (file)
@@ -42,6 +42,7 @@
 #include "comm/IoCallback.h"
 #include "comm/Write.h"
 #include "comm/ListenStateData.h"
+#include "comm/Loops.h"
 #include "CommIO.h"
 #include "CommRead.h"
 #include "ConnectionDetail.h"
@@ -183,7 +184,7 @@ commHandleRead(int fd, void *data)
     }
 
     /* Nope, register for some more IO */
-    commSetSelect(fd, COMM_SELECT_READ, commHandleRead, data, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, commHandleRead, data, 0);
 }
 
 /**
@@ -219,7 +220,7 @@ comm_read(int fd, char *buf, int size, AsyncCall::Pointer &callback)
 
     /* Queue the read */
     ccb->setCallback(Comm::IOCB_READ, callback, (char *)buf, NULL, size);
-    commSetSelect(fd, COMM_SELECT_READ, commHandleRead, ccb, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, commHandleRead, ccb, 0);
 }
 
 /**
@@ -319,7 +320,7 @@ comm_read_cancel(int fd, IOCB *callback, void *data)
     cb->cancel("old comm_read_cancel");
 
     /* And the IO event */
-    commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
 void
@@ -349,7 +350,7 @@ comm_read_cancel(int fd, AsyncCall::Pointer &callback)
     cb->cancel("comm_read_cancel");
 
     /* And the IO event */
-    commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
 
@@ -936,7 +937,7 @@ ConnectStateData::commResetFD()
         F->local_addr.FreeAddrInfo(AI);
         return 0;
     }
-    commResetSelect(fd);
+    Comm::ResetSelect(fd);
 
     close(fd2);
 
@@ -1036,7 +1037,7 @@ ConnectStateData::connect()
 
     case COMM_INPROGRESS:
         debugs(5, 5, HERE << "FD " << fd << ": COMM_INPROGRESS");
-        commSetSelect(fd, COMM_SELECT_WRITE, ConnectStateData::Connect, this, 0);
+        Comm::SetSelect(fd, COMM_SELECT_WRITE, ConnectStateData::Connect, this, 0);
         break;
 
     case COMM_OK:
@@ -1356,7 +1357,7 @@ comm_lingering_close(int fd)
 
     fd_note(fd, "lingering close");
     commSetTimeout(fd, 10, commLingerTimeout, NULL);
-    commSetSelect(fd, COMM_SELECT_READ, commLingerClose, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, commLingerClose, NULL, 0);
 }
 
 #endif
@@ -1468,11 +1469,11 @@ _comm_close(int fd, char const *file, int line)
 
     // notify read/write handlers after canceling select reservations, if any
     if (COMMIO_FD_WRITECB(fd)->active()) {
-        commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+        Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
         COMMIO_FD_WRITECB(fd)->finish(COMM_ERR_CLOSING, errno);
     }
     if (COMMIO_FD_READCB(fd)->active()) {
-        commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+        Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
         COMMIO_FD_READCB(fd)->finish(COMM_ERR_CLOSING, errno);
     }
 
@@ -1810,6 +1811,9 @@ comm_init(void)
     conn_close_pool = memPoolCreate("close_handler", sizeof(close_handler));
 
     TheHalfClosed = new DescriptorSet;
+
+    /* setup the select loop module */
+    Comm::SelectLoopInit();
 }
 
 void
@@ -1851,7 +1855,7 @@ commHandleWriteHelper(void * data)
                 !fd_table[head].closing()) {
 
             // wait for the head descriptor to become ready for writing
-            commSetSelect(head, COMM_SELECT_WRITE, Comm::HandleWrite, ccb, 0);
+            Comm::SetSelect(head, COMM_SELECT_WRITE, Comm::HandleWrite, ccb, 0);
             clientInfo->selectWaiting = true;
             return;
         }
@@ -2154,7 +2158,7 @@ checkTimeouts(void)
         if (writeTimedOut(fd)) {
             // We have an active write callback and we are timed out
             debugs(5, 5, "checkTimeouts: FD " << fd << " auto write timeout");
-            commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+            Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
             COMMIO_FD_WRITECB(fd)->finish(COMM_ERROR, ETIMEDOUT);
         } else if (AlreadyTimedOut(F))
             continue;
@@ -2184,7 +2188,7 @@ void CommIO::Initialise()
     fd_open(DoneFD, FD_PIPE, "async-io completetion event: threads");
     commSetNonBlocking(DoneReadFD);
     commSetNonBlocking(DoneFD);
-    commSetSelect(DoneReadFD, COMM_SELECT_READ, NULLFDHandler, NULL, 0);
+    Comm::SetSelect(DoneReadFD, COMM_SELECT_READ, NULLFDHandler, NULL, 0);
     Initialised = true;
 }
 
@@ -2215,7 +2219,7 @@ void
 CommIO::NULLFDHandler(int fd, void *data)
 {
     FlushPipe();
-    commSetSelect(fd, COMM_SELECT_READ, NULLFDHandler, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, NULLFDHandler, NULL, 0);
 }
 
 void
@@ -2458,7 +2462,7 @@ CommSelectEngine::checkEvents(int timeout)
         checkTimeouts();
     }
 
-    switch (comm_select(timeout)) {
+    switch (Comm::DoSelect(timeout)) {
 
     case COMM_OK:
 
index ed3217c8b82b0f3012c5ff292cb6bf3a87e3e21c..fb206c93de3a944940feb47c0321b8c9d7818480 100644 (file)
@@ -61,9 +61,6 @@ SQUIDCEXTERN int comm_open_listener(int sock_type, int proto, Ip::Address &addr,
 SQUIDCEXTERN int comm_openex(int, int, Ip::Address &, int, tos_t tos, nfmark_t nfmark, const char *);
 SQUIDCEXTERN u_short comm_local_port(int fd);
 
-SQUIDCEXTERN void commSetSelect(int, unsigned int, PF *, void *, time_t);
-SQUIDCEXTERN void commResetSelect(int);
-
 SQUIDCEXTERN int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen);
 SQUIDCEXTERN void commCallCloseHandlers(int fd);
 SQUIDCEXTERN int commSetTimeout(int fd, int, PF *, void *);
@@ -73,13 +70,6 @@ SQUIDCEXTERN void commCloseAllSockets(void);
 SQUIDCEXTERN void checkTimeouts(void);
 
 
-/*
- * comm_select.c
- */
-SQUIDCEXTERN void comm_select_init(void);
-SQUIDCEXTERN comm_err_t comm_select(int);
-SQUIDCEXTERN void comm_quick_poll_required(void);
-
 class ConnectionDetail;
 typedef void IOACB(int fd, int nfd, ConnectionDetail *details, comm_err_t flag, int xerrno, void *data);
 extern void comm_add_close_handler(int fd, PF *, void *);
index 4e5b2bdf560b7f3a90d2cd84366f004dc8c394aa..4026737754f8837cfe4e1ab8e09d7f860e976ed0 100644 (file)
@@ -1,6 +1,7 @@
 #include "config.h"
 #include "ClientInfo.h"
 #include "comm/IoCallback.h"
+#include "comm/Loops.h"
 #include "comm/Write.h"
 #include "CommCalls.h"
 #include "fde.h"
@@ -65,7 +66,7 @@ Comm::IoCallback::selectOrQueueWrite()
     }
 #endif
 
-    commSetSelect(fd, COMM_SELECT_WRITE, Comm::HandleWrite, this, 0);
+    SetSelect(fd, COMM_SELECT_WRITE, Comm::HandleWrite, this, 0);
 }
 
 void
index 838d7ff5f7ed9c3ecae6d1f7b3230bb46f542783..62816145f569a35f1c15105431fb398b482fe9f5 100644 (file)
@@ -37,6 +37,7 @@
 #include "comm/AcceptLimiter.h"
 #include "comm/comm_internal.h"
 #include "comm/ListenStateData.h"
+#include "comm/Loops.h"
 #include "ConnectionDetail.h"
 #include "fde.h"
 #include "protos.h"
@@ -88,7 +89,7 @@ Comm::ListenStateData::ListenStateData(int aFd, AsyncCall::Pointer &call, bool a
     debugs(5, 5, HERE << "FD " << fd << " AsyncCall: " << call);
     assert(isOpen(aFd));
     setListen();
-    commSetSelect(fd, COMM_SELECT_READ, doAccept, this, 0);
+    SetSelect(fd, COMM_SELECT_READ, doAccept, this, 0);
 }
 
 Comm::ListenStateData::~ListenStateData()
@@ -119,7 +120,7 @@ Comm::ListenStateData::doAccept(int fd, void *data)
     } else {
         afd->acceptNext();
     }
-    commSetSelect(fd, COMM_SELECT_READ, Comm::ListenStateData::doAccept, afd, 0);
+    SetSelect(fd, COMM_SELECT_READ, Comm::ListenStateData::doAccept, afd, 0);
 }
 
 bool
@@ -157,7 +158,7 @@ Comm::ListenStateData::acceptOne()
         if (newfd == COMM_NOMESSAGE) {
             /* register interest again */
             debugs(5, 5, HERE << "try later: FD " << fd << " handler: " << theCallback);
-            commSetSelect(fd, COMM_SELECT_READ, doAccept, this, 0);
+            SetSelect(fd, COMM_SELECT_READ, doAccept, this, 0);
             return;
         }
 
diff --git a/src/comm/Loops.h b/src/comm/Loops.h
new file mode 100644 (file)
index 0000000..6d5ec34
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef _SQUID_SRC_COMM_LOOPS_H
+#define _SQUID_SRC_COMM_LOOPS_H
+
+#include "comm_err_t.h"
+
+/* Comm layer select loops API.
+ *
+ * These API functions must be implemented by all FD IO loops used by Squid.
+ * Defines are provided short-term for legacy code. These will disappear soon.
+ */
+
+namespace Comm {
+
+/// Initialize the module on Squid startup
+extern void SelectLoopInit(void);
+
+/// Mark an FD to be watched for its IO status.
+extern void SetSelect(int, unsigned int, PF *, void *, time_t);
+
+/// reset/undo/unregister the watch for an FD which was set by Comm::SetSelect()
+extern void ResetSelect(int);
+
+/** Perform a select() or equivalent call.
+ * This is used by the main select loop engine to check for FD with IO available.
+ */
+extern comm_err_t DoSelect(int);
+
+extern void QuickPollRequired(void);
+
+} // namespace Comm
+
+#endif /* _SQUID_SRC_COMM_LOOPS_H */
index 6a2c3f38716c589fb58fc125cf15cc792e03fd2c..3ddf7797da262b7b81c470d2e9849ec632490cc6 100644 (file)
@@ -9,6 +9,13 @@ libcomm_la_SOURCES= \
        AcceptLimiter.h \
        ListenStateData.cc \
        ListenStateData.h \
+       Loops.h \
+       ModDevPoll.cc \
+       ModEpoll.cc \
+       ModKqueue.cc \
+       ModPoll.cc \
+       ModSelect.cc \
+       ModSelectWin32.cc \
        \
        IoCallback.cc \
        IoCallback.h \
similarity index 96%
rename from src/comm_devpoll.cc
rename to src/comm/ModDevPoll.cc
index c42ecea31ff29eb6b53a8e49f87aaa93e75774a4..7cf65131a0eff10918269694e44d3ce54e3ffea8 100644 (file)
  * Last modified 2010-10-08
  */
 
-
-#include "squid.h"
-
 /*
  * There are several poll types in Squid, ALL of which are compiled and linked
  * in. Thus conditional compile-time flags are used to prevent the different
  * modules from creating several versions of the same function simultaneously.
  */
 
+#include "config.h"
+
 #if USE_DEVPOLL
 
-#include "Store.h"
+#include "squid.h"
+#include "comm/Loops.h"
 #include "fde.h"
 #include "mgr/Registration.h"
 #include "SquidTime.h"
+#include "Store.h"
 
 #if HAVE_SYS_DEVPOLL_H
 /* Solaris /dev/poll support, see "man -s 7D poll" */
@@ -198,7 +199,7 @@ commDevPollRegisterWithCacheManager(void)
  * Allocates memory, opens /dev/poll device handle.
  */
 void
-comm_select_init(void)
+Comm::SelectLoopInit(void)
 {
     /* allocate memory first before attempting to open poll device */
     /* This tracks the FD devpoll offset+state */
@@ -243,8 +244,7 @@ comm_select_init(void)
  * @param timeout if non-zero then timeout relative to now
  */
 void
-commSetSelect(int fd, unsigned int type, PF * handler,
-              void *client_data, time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     assert(fd >= 0);
     debugs(
@@ -325,10 +325,10 @@ commSetSelect(int fd, unsigned int type, PF * handler,
  * @param fd file descriptor to clear polling on
  */
 void
-commResetSelect(int fd)
+Comm::ResetSelect(int fd)
 {
-    commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
-    commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+    SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+    SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
 
@@ -346,7 +346,7 @@ commResetSelect(int fd)
  * @param msec milliseconds to poll for (limited by max_poll_time)
  */
 comm_err_t
-comm_select(int msec)
+Comm::DoSelect(int msec)
 {
     int num, i;
     fde *F;
@@ -432,7 +432,7 @@ comm_select(int msec)
                     HERE << "no read handler for FD " << fd
                 );
                 // remove interest since no handler exist for this event.
-                commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+                SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
             }
         }
 
@@ -456,7 +456,7 @@ comm_select(int msec)
                     HERE << "no write handler for FD " << fd
                 );
                 // remove interest since no handler exist for this event.
-                commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+                SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
             }
         }
     }
@@ -465,9 +465,8 @@ comm_select(int msec)
     return COMM_OK;
 }
 
-
 void
-comm_quick_poll_required(void)
+Comm::QuickPollRequired(void)
 {
     max_poll_time = 10;
 }
similarity index 86%
rename from src/comm_epoll.cc
rename to src/comm/ModEpoll.cc
index d46279c206cc13d370198bc1cd2bea4c79543a29..af9790ace8f6ad382b7d12e9435203a527a40ab0 100644 (file)
  *
  */
 
+#include "config.h"
+
+#if USE_EPOLL
+
 #include "squid.h"
-#include "comm_epoll.h"
-#include "mgr/Registration.h"
-#include "Store.h"
+#include "comm/Loops.h"
 #include "fde.h"
+#include "mgr/Registration.h"
 #include "SquidTime.h"
-
-#if USE_EPOLL
+#include "Store.h"
 
 #define DEBUG_EPOLL 0
 
@@ -79,15 +81,12 @@ static void commEPollRegisterWithCacheManager(void);
 
 
 /*
- * comm_select_init
- *
  * This is a needed exported function which will be called to initialise
  * the network loop code.
  */
 void
-comm_select_init(void)
+Comm::SelectLoopInit(void)
 {
-
     pevents = (struct epoll_event *) xmalloc(SQUID_MAXFD * sizeof(struct epoll_event));
 
     if (!pevents) {
@@ -121,25 +120,21 @@ static const char* epolltype_atoi(int x)
     }
 }
 
-/*
- * comm_setselect
- *
+/**
  * This is a needed exported function which will be called to register
  * and deregister interest in a pending IO state for a given FD.
- *
  */
 void
-commSetSelect(int fd, unsigned int type, PF * handler,
-              void *client_data, time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     fde *F = &fd_table[fd];
     int epoll_ctl_type = 0;
 
     struct epoll_event ev;
     assert(fd >= 0);
-    debugs(5, DEBUG_EPOLL ? 0 : 8, "commSetSelect(FD " << fd << ",type=" << type <<
-           ",handler=" << handler << ",client_data=" << client_data <<
-           ",timeout=" << timeout << ")");
+    debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "FD " << fd << ", type=" << type <<
+           ", handler=" << handler << ", client_data=" << client_data <<
+           ", timeout=" << timeout);
 
     if (RUNNING_ON_VALGRIND) {
         /* Keep valgrind happy.. complains about uninitialized bytes otherwise */
@@ -198,7 +193,7 @@ commSetSelect(int fd, unsigned int type, PF * handler,
         F->epoll_state = ev.events;
 
         if (epoll_ctl(kdpfd, epoll_ctl_type, fd, &ev) < 0) {
-            debugs(5, DEBUG_EPOLL ? 0 : 8, "commSetSelect: epoll_ctl(," << epolltype_atoi(epoll_ctl_type) <<
+            debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "epoll_ctl(," << epolltype_atoi(epoll_ctl_type) <<
                    ",,): failed on FD " << fd << ": " << xstrerror());
         }
     }
@@ -208,11 +203,11 @@ commSetSelect(int fd, unsigned int type, PF * handler,
 }
 
 void
-commResetSelect(int fd)
+Comm::ResetSelect(int fd)
 {
     fde *F = &fd_table[fd];
     F->epoll_state = 0;
-    commSetSelect(fd, 0, NULL, NULL, 0);
+    SetSelect(fd, 0, NULL, NULL, 0);
 }
 
 
@@ -235,8 +230,7 @@ commIncomingStats(StoreEntry * sentry)
     statHistDump(&f->select_fds_hist, sentry, statHistIntDumper);
 }
 
-/*
- * comm_select
+/**
  * Check all connections for new connections and input data that is to be
  * processed. Also check for connections with data queued and whether we can
  * write it out.
@@ -246,9 +240,8 @@ commIncomingStats(StoreEntry * sentry)
  * comm_setselect and fd_table[] and calls callbacks for IO ready
  * events.
  */
-
 comm_err_t
-comm_select(int msec)
+Comm::DoSelect(int msec)
 {
     int num, i,fd;
     fde *F;
@@ -291,7 +284,7 @@ comm_select(int msec)
     for (i = 0, cevents = pevents; i < num; i++, cevents++) {
         fd = cevents->data.fd;
         F = &fd_table[fd];
-        debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): got FD " << fd << " events=" <<
+        debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "got FD " << fd << " events=" <<
                std::hex << cevents->events << " monitoring=" << F->epoll_state <<
                " F->read_handler=" << F->read_handler << " F->write_handler=" << F->write_handler);
 
@@ -299,7 +292,7 @@ comm_select(int msec)
 
         if (cevents->events & (EPOLLIN|EPOLLHUP|EPOLLERR) || F->flags.read_pending) {
             if ((hdl = F->read_handler) != NULL) {
-                debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): Calling read handler on FD " << fd);
+                debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "Calling read handler on FD " << fd);
                 PROF_start(comm_write_handler);
                 F->flags.read_pending = 0;
                 F->read_handler = NULL;
@@ -307,24 +300,24 @@ comm_select(int msec)
                 PROF_stop(comm_write_handler);
                 statCounter.select_fds++;
             } else {
-                debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): no read handler for FD " << fd);
+                debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "no read handler for FD " << fd);
                 // remove interest since no handler exist for this event.
-                commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+                SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
             }
         }
 
         if (cevents->events & (EPOLLOUT|EPOLLHUP|EPOLLERR)) {
             if ((hdl = F->write_handler) != NULL) {
-                debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): Calling write handler on FD " << fd);
+                debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "Calling write handler on FD " << fd);
                 PROF_start(comm_read_handler);
                 F->write_handler = NULL;
                 hdl(fd, F->write_data);
                 PROF_stop(comm_read_handler);
                 statCounter.select_fds++;
             } else {
-                debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): no write handler for FD " << fd);
+                debugs(5, DEBUG_EPOLL ? 0 : 8, HERE << "no write handler for FD " << fd);
                 // remove interest since no handler exist for this event.
-                commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+                SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
             }
         }
     }
@@ -335,7 +328,7 @@ comm_select(int msec)
 }
 
 void
-comm_quick_poll_required(void)
+Comm::QuickPollRequired(void)
 {
     max_poll_time = 10;
 }
similarity index 97%
rename from src/comm_kqueue.cc
rename to src/comm/ModKqueue.cc
index 70b94ddeba1fc7a4a33990b75b9db893c39dcdd4..01aa65a519ffa5550783abb6d5c3c65348502304 100644 (file)
  * so deferred reads aren't required.
  *  -- adrian
  */
-
-#include "squid.h"
+#include "config.h"
 
 #if USE_KQUEUE
 
-#include "comm_kqueue.h"
-#include "Store.h"
+#include "squid.h"
+#include "comm/Loops.h"
 #include "fde.h"
+#include "Store.h"
 #include "SquidTime.h"
 
 #if HAVE_SYS_EVENT_H
@@ -165,7 +165,7 @@ kq_update_events(int fd, short filter, PF * handler)
  * the network loop code.
  */
 void
-comm_select_init(void)
+Comm::SelectLoopInit(void)
 {
     kq = kqueue();
 
@@ -189,8 +189,7 @@ comm_select_init(void)
  * and deregister interest in a pending IO state for a given FD.
  */
 void
-commSetSelect(int fd, unsigned int type, PF * handler,
-              void *client_data, time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     fde *F = &fd_table[fd];
     assert(fd >= 0);
@@ -214,7 +213,7 @@ commSetSelect(int fd, unsigned int type, PF * handler,
 }
 
 void
-commResetSelect(int fd)
+Comm::ResetSelect(int fd)
 {
     fde *F = &fd_table[fd];
     if (F->read_handler) {
@@ -241,7 +240,7 @@ commResetSelect(int fd)
  */
 
 comm_err_t
-comm_select(int msec)
+Comm::Select(int msec)
 {
     int num, i;
 
@@ -322,7 +321,7 @@ comm_select(int msec)
 }
 
 void
-comm_quick_poll_required(void)
+Comm::QuickPollRequired(void)
 {
     max_poll_time = 10;
 }
similarity index 98%
rename from src/comm_poll.cc
rename to src/comm/ModPoll.cc
index 60bc70a29add1cb14ea9343e6c1071ce753295bd..095d0b56e4df65894639843f08e6676ff5d20335 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
  *
  */
+#include "config.h"
+
+#if USE_POLL
 
 #include "squid.h"
-#include "comm_poll.h"
+#include "comm/Loops.h"
+#include "fde.h"
 #include "mgr/Registration.h"
 #include "SquidTime.h"
 #include "Store.h"
-#include "fde.h"
-
-#if USE_POLL
 
 #if HAVE_POLL_H
 #include <poll.h>
@@ -54,7 +55,7 @@
 #endif
 #endif
 
-static int MAX_POLL_TIME = 1000;       /* see also comm_quick_poll_required() */
+static int MAX_POLL_TIME = 1000;       /* see also Comm::QuickPollRequired() */
 
 #ifndef        howmany
 #define howmany(x, y)   (((x)+((y)-1))/(y))
@@ -136,8 +137,7 @@ static int incoming_http_interval = 16 << INCOMING_FACTOR;
 
 
 void
-commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
-              time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     fde *F = &fd_table[fd];
     assert(fd >= 0);
@@ -159,7 +159,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
 }
 
 void
-commResetSelect(int fd)
+Comm::ResetSelect(int fd)
 {
 }
 
@@ -341,9 +341,8 @@ comm_poll_http_incoming(void)
 
 /* poll all sockets; call handlers for those that are ready. */
 comm_err_t
-comm_select(int msec)
+Comm::DoSelect(int msec)
 {
-
     struct pollfd pfds[SQUID_MAXFD];
 
     PF *hdl = NULL;
@@ -631,7 +630,7 @@ commPollRegisterWithCacheManager(void)
 }
 
 void
-comm_select_init(void)
+Comm::SelectLoopInit(void)
 {
     commPollRegisterWithCacheManager();
 }
@@ -658,7 +657,7 @@ commIncomingStats(StoreEntry * sentry)
 
 /* Called by async-io or diskd to speed up the polling */
 void
-comm_quick_poll_required(void)
+Comm::QuickPollRequired(void)
 {
     MAX_POLL_TIME = 10;
 }
similarity index 97%
rename from src/comm_select.cc
rename to src/comm/ModSelect.cc
index ee8617d617c9de63d603d3d6ac7cb4e1ba140351..a32b47bbc019bcd83e30872f5ba216e2774a9ef8 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
  *
  */
+#include "config.h"
+
+#if USE_SELECT
 
 #include "squid.h"
-#include "comm_select.h"
+#include "comm/Loops.h"
 #include "mgr/Registration.h"
 #include "SquidTime.h"
-
-#if USE_SELECT
 #include "Store.h"
 #include "fde.h"
 
-static int MAX_POLL_TIME = 1000;       /* see also comm_quick_poll_required() */
+static int MAX_POLL_TIME = 1000;       /* see also Comm::QuickPollRequired() */
 
 #ifndef        howmany
 #define howmany(x, y)   (((x)+((y)-1))/(y))
@@ -131,13 +132,12 @@ static int incoming_http_interval = 16 << INCOMING_FACTOR;
 #define commCheckHTTPIncoming (++http_io_events > (incoming_http_interval>> INCOMING_FACTOR))
 
 void
-commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
-              time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     fde *F = &fd_table[fd];
     assert(fd >= 0);
     assert(F->flags.open);
-    debugs(5, 5, "commSetSelect: FD " << fd << " type " << type);
+    debugs(5, 5, HERE << "FD " << fd << " type " << type);
 
     if (type & COMM_SELECT_READ) {
         F->read_handler = handler;
@@ -156,7 +156,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
 }
 
 void
-commResetSelect(int fd)
+Comm::ResetSelect(int fd)
 {
 }
 
@@ -333,7 +333,7 @@ comm_select_http_incoming(void)
 #define DEBUG_FDBITS 0
 /* Select on all sockets; call handlers for those that are ready. */
 comm_err_t
-comm_select(int msec)
+Comm::DoSelect(int msec)
 {
     fd_set readfds;
     fd_set pendingfds;
@@ -660,16 +660,8 @@ comm_select_dns_incoming(void)
     statHistCount(&statCounter.comm_dns_incoming, nevents);
 }
 
-static void
-commSelectRegisterWithCacheManager(void)
-{
-    Mgr::RegisterAction("comm_select_incoming",
-                        "comm_incoming() stats",
-                        commIncomingStats, 0, 1);
-}
-
 void
-comm_select_init(void)
+Comm::SelectLoopInit(void)
 {
     zero_tv.tv_sec = 0;
     zero_tv.tv_usec = 0;
@@ -677,7 +669,9 @@ comm_select_init(void)
     FD_ZERO(&global_writefds);
     nreadfds = nwritefds = 0;
 
-    commSelectRegisterWithCacheManager();
+    Mgr::RegisterAction("comm_select_incoming",
+                        "comm_incoming() stats",
+                        commIncomingStats, 0, 1);
 }
 
 /*
@@ -798,7 +792,7 @@ commUpdateWriteBits(int fd, PF * handler)
 
 /* Called by async-io or diskd to speed up the polling */
 void
-comm_quick_poll_required(void)
+Comm::QuickPollRequired(void)
 {
     MAX_POLL_TIME = 10;
 }
similarity index 98%
rename from src/comm_select_win32.cc
rename to src/comm/ModSelectWin32.cc
index 74a13089f7c8c2d3870d3b4b66e7d0991155a4ac..2e190904fa8c38e42f746081d3c89f9a2bb2ddd5 100644 (file)
  *
  */
 
+#include "config.h"
+
+#if USE_SELECT_WIN32
+
 #include "squid.h"
-#include "comm_select.h"
+#include "comm/Loops.h"
+#include "fde.h"
 #include "mgr/Registration.h"
 #include "SquidTime.h"
-
-#if USE_SELECT_WIN32
 #include "Store.h"
-#include "fde.h"
 
-static int MAX_POLL_TIME = 1000;       /* see also comm_quick_poll_required() */
+static int MAX_POLL_TIME = 1000;       /* see also Comm::QuickPollRequired() */
 
 #ifndef        howmany
 #define howmany(x, y)   (((x)+((y)-1))/(y))
@@ -131,8 +133,7 @@ static int incoming_http_interval = 16 << INCOMING_FACTOR;
 #define commCheckHTTPIncoming (++http_io_events > (incoming_http_interval>> INCOMING_FACTOR))
 
 void
-commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
-              time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     fde *F = &fd_table[fd];
     assert(fd >= 0);
@@ -156,7 +157,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
 }
 
 void
-commResetSelect(int fd)
+Comm::ResetSelect(int fd)
 {
 }
 
@@ -336,7 +337,7 @@ comm_select_http_incoming(void)
 #define DEBUG_FDBITS 0
 /* Select on all sockets; call handlers for those that are ready. */
 comm_err_t
-comm_select(int msec)
+Comm::DoSelect(int msec)
 {
     fd_set readfds;
     fd_set pendingfds;
@@ -682,16 +683,8 @@ comm_select_dns_incoming(void)
     statHistCount(&statCounter.comm_dns_incoming, nevents);
 }
 
-static void
-commSelectRegisterWithCacheManager(void)
-{
-    Mgr::RegisterAction("comm_select_incoming",
-                        "comm_incoming() stats",
-                        commIncomingStats, 0, 1);
-}
-
 void
-comm_select_init(void)
+Comm::SelectLoopInit(void)
 {
     zero_tv.tv_sec = 0;
     zero_tv.tv_usec = 0;
@@ -699,7 +692,9 @@ comm_select_init(void)
     FD_ZERO(&global_writefds);
     nreadfds = nwritefds = 0;
 
-    commSelectRegisterWithCacheManager();
+    Mgr::RegisterAction("comm_select_incoming",
+                        "comm_incoming() stats",
+                        commIncomingStats, 0, 1);
 }
 
 /*
@@ -820,7 +815,7 @@ commUpdateWriteBits(int fd, PF * handler)
 
 /* Called by async-io or diskd to speed up the polling */
 void
-comm_quick_poll_required(void)
+Comm::QuickPollRequired(void)
 {
     MAX_POLL_TIME = 10;
 }
diff --git a/src/comm_epoll.h b/src/comm_epoll.h
deleted file mode 100644 (file)
index 90c10a4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-
-/*
- * $Id$
- *
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#ifndef SQUID_COMM_EPOLL_H
-#define SQUID_COMM_EPOLL_H
-
-#endif /* SQUID_COMM_EPOLL_H */
diff --git a/src/comm_kqueue.h b/src/comm_kqueue.h
deleted file mode 100644 (file)
index 0c8e248..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-
-/*
- * $Id$
- *
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#ifndef SQUID_COMM_KQUEUE_H
-#define SQUID_COMM_KQUEUE_H
-
-#endif /* SQUID_COMM_KQUEUE_H */
diff --git a/src/comm_select.h b/src/comm_select.h
deleted file mode 100644 (file)
index 9365f83..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-
-/*
- * $Id$
- *
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-#ifndef SQUID_COMM_SELECT_H
-#define SQUID_COMM_SELECT_H
-
-
-#endif /* SQUID_COMM_SELECT_H */
index 828353219b0e82ca8d5f4501ab67fd83f99f0072..b2cb3cdda7959b0922391adfa445693ac2bbd710 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include "squid.h"
+#include "comm/Loops.h"
 #include "fde.h"
 #include "MemBuf.h"
 
@@ -329,7 +330,7 @@ diskHandleWrite(int fd, void *notused)
     } else {
         /* another block is queued */
         diskCombineWrites(fdd);
-        commSetSelect(fd, COMM_SELECT_WRITE, diskHandleWrite, NULL, 0);
+        Comm::SetSelect(fd, COMM_SELECT_WRITE, diskHandleWrite, NULL, 0);
         F->flags.write_daemon = 1;
     }
 
@@ -458,7 +459,7 @@ diskHandleRead(int fd, void *data)
 
     if (len < 0) {
         if (ignoreErrno(errno)) {
-            commSetSelect(fd, COMM_SELECT_READ, diskHandleRead, ctrl_dat, 0);
+            Comm::SetSelect(fd, COMM_SELECT_READ, diskHandleRead, ctrl_dat, 0);
             PROF_stop(diskHandleRead);
             return;
         }
index 95dd38a2770e36afd0e7bc160b23b571c68a5924..f859e9dcb7ad47b7a5af45e4c9600a3a7406cdc4 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * $Id$
  *
  *
  */
 
-#include "config.h"
 #include "squid.h"
+#include "comm.h"
+#include "comm/Loops.h"
+#include "comm/Write.h"
 #include "event.h"
 #include "SquidTime.h"
 #include "Store.h"
-#include "comm.h"
-#include "comm/Write.h"
 #include "fde.h"
 #include "ip/tools.h"
 #include "MemBuf.h"
@@ -1238,7 +1237,7 @@ idnsRead(int fd, void *data)
 
     // Always keep reading. This stops (or at least makes harder) several
     // attacks on the DNS client.
-    commSetSelect(fd, COMM_SELECT_READ, idnsRead, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, idnsRead, NULL, 0);
 
     /* BUG (UNRESOLVED)
      *  two code lines after returning from comm_udprecvfrom()
@@ -1496,12 +1495,12 @@ idnsInit(void)
         if (DnsSocketB >= 0) {
             port = comm_local_port(DnsSocketB);
             debugs(78, 1, "DNS Socket created at " << addrB << ", FD " << DnsSocketB);
-            commSetSelect(DnsSocketB, COMM_SELECT_READ, idnsRead, NULL, 0);
+            Comm::SetSelect(DnsSocketB, COMM_SELECT_READ, idnsRead, NULL, 0);
         }
         if (DnsSocketA >= 0) {
             port = comm_local_port(DnsSocketA);
             debugs(78, 1, "DNS Socket created at " << addrA << ", FD " << DnsSocketA);
-            commSetSelect(DnsSocketA, COMM_SELECT_READ, idnsRead, NULL, 0);
+            Comm::SetSelect(DnsSocketA, COMM_SELECT_READ, idnsRead, NULL, 0);
         }
     }
 
index e895d9c1f4b8820d4d7c41d2e6dbc8c404be8aa8..d3e685c63f12f401314954bfa3de6dbc817ce0aa 100644 (file)
--- a/src/fd.cc
+++ b/src/fd.cc
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "comm/Loops.h"
 #include "fde.h"
 #include "SquidTime.h"
 #include "Debug.h"
@@ -110,8 +111,8 @@ fd_close(int fd)
     }
 
     debugs(51, 3, "fd_close FD " << fd << " " << F->desc);
-    commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
-    commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
     F->flags.open = 0;
     fdUpdateBiggest(fd, 0);
     Number_FD--;
index b30b3d6aea81d115e6ef8e73005900ecd508d2a0..930a11062937c5e3b7ab64221d1bdde68d76e9e9 100644 (file)
@@ -36,6 +36,7 @@
 #include "acl/FilledChecklist.h"
 #include "acl/Gadgets.h"
 #include "CacheManager.h"
+#include "comm/Loops.h"
 #include "event.h"
 #include "errorpage.h"
 #include "fde.h"
@@ -585,11 +586,11 @@ FwdState::negotiateSSL(int fd)
         switch (ssl_error) {
 
         case SSL_ERROR_WANT_READ:
-            commSetSelect(fd, COMM_SELECT_READ, fwdNegotiateSSLWrapper, this, 0);
+            Comm::SetSelect(fd, COMM_SELECT_READ, fwdNegotiateSSLWrapper, this, 0);
             return;
 
         case SSL_ERROR_WANT_WRITE:
-            commSetSelect(fd, COMM_SELECT_WRITE, fwdNegotiateSSLWrapper, this, 0);
+            Comm::SetSelect(fd, COMM_SELECT_WRITE, fwdNegotiateSSLWrapper, this, 0);
             return;
 
         default:
index df13aa591fa9743db36857e99cefefea78e14ace..0f6b30719737135a86bc68effaa0564feecfa434 100644 (file)
  */
 
 #include "squid.h"
-#include "htcp.h"
+#include "AccessLogEntry.h"
 #include "acl/FilledChecklist.h"
 #include "acl/Acl.h"
-#include "ip/tools.h"
-#include "SquidTime.h"
-#include "Store.h"
-#include "StoreClient.h"
-#include "HttpRequest.h"
 #include "comm.h"
-#include "MemBuf.h"
+#include "comm/Loops.h"
+#include "htcp.h"
 #include "http.h"
+#include "HttpRequest.h"
 #include "icmp/net_db.h"
-#include "AccessLogEntry.h"
 #include "ipc/StartListening.h"
+#include "ip/tools.h"
+#include "MemBuf.h"
+#include "SquidTime.h"
+#include "Store.h"
+#include "StoreClient.h"
 
 /// dials htcpIncomingConnectionOpened call
 class HtcpListeningStartedDialer: public CallDialer,
@@ -1484,7 +1485,7 @@ htcpRecv(int fd, void *data)
 
     htcpHandleMsg(buf, len, from);
 
-    commSetSelect(fd, COMM_SELECT_READ, htcpRecv, NULL, 0);
+    Comm::SetSelect(fd, COMM_SELECT_READ, htcpRecv, NULL, 0);
 }
 
 /*
@@ -1547,7 +1548,7 @@ htcpInit(void)
         if (htcpOutSocket < 0)
             fatal("Cannot open Outgoing HTCP Socket");
 
-        commSetSelect(htcpOutSocket, COMM_SELECT_READ, htcpRecv, NULL, 0);
+        Comm::SetSelect(htcpOutSocket, COMM_SELECT_READ, htcpRecv, NULL, 0);
 
         debugs(31, 1, "Outgoing HTCP messages on port " << Config.Port.htcp << ", FD " << htcpOutSocket << ".");
 
@@ -1567,7 +1568,7 @@ htcpIncomingConnectionOpened(int fd, int errNo)
     if (htcpInSocket < 0)
         fatal("Cannot open HTCP Socket");
 
-    commSetSelect(htcpInSocket, COMM_SELECT_READ, htcpRecv, NULL, 0);
+    Comm::SetSelect(htcpInSocket, COMM_SELECT_READ, htcpRecv, NULL, 0);
 
     debugs(31, 1, "Accepting HTCP messages on port " << Config.Port.htcp << ", FD " << htcpInSocket << ".");
 
@@ -1733,7 +1734,7 @@ htcpSocketShutdown(void)
      */
     assert(htcpOutSocket > -1);
 
-    commSetSelect(htcpOutSocket, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(htcpOutSocket, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
 void
index 708f4f4866a1104d9698f65dc26e49cb012bea31..d530553164703d1d373b7b9d41b63f2d85b2b3b9 100644 (file)
  */
 
 #include "squid.h"
+#include "comm.h"
+#include "comm/Loops.h"
 #include "icmp/IcmpSquid.h"
 #include "icmp/net_db.h"
 #include "ip/tools.h"
-#include "comm.h"
 #include "SquidTime.h"
 
 // Instance global to be available in main() and elsewhere.
@@ -144,7 +145,7 @@ IcmpSquid::Recv()
     pingerReplyData preply;
     static Ip::Address F;
 
-    commSetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
+    Comm::SetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
     memset(&preply, '\0', sizeof(pingerReplyData));
     n = comm_udp_recv(icmp_sock,
                       (char *) &preply,
@@ -247,7 +248,7 @@ IcmpSquid::Open(void)
 
     fd_note(icmp_sock, "pinger");
 
-    commSetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
+    Comm::SetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
 
     commSetTimeout(icmp_sock, -1, NULL, NULL);
 
index d09aea28aa668f3696feb35e1d195ec7a14a37fb..2f1d326517a0d1c700e387477b62ac048591c44f 100644 (file)
@@ -38,6 +38,7 @@
 #include "squid.h"
 #include "Store.h"
 #include "comm.h"
+#include "comm/Loops.h"
 #include "ICP.h"
 #include "HttpRequest.h"
 #include "acl/FilledChecklist.h"
@@ -337,7 +338,7 @@ icpUdpSend(int fd,
             IcpQueueTail = queue;
         }
 
-        commSetSelect(fd, COMM_SELECT_WRITE, icpUdpSendQueue, NULL, 0);
+        Comm::SetSelect(fd, COMM_SELECT_WRITE, icpUdpSendQueue, NULL, 0);
         statCounter.icp.replies_queued++;
     } else {
         /* don't queue it */
@@ -616,7 +617,7 @@ icpHandleUdp(int sock, void *data)
     int len;
     int icp_version;
     int max = INCOMING_ICP_MAX;
-    commSetSelect(sock, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
+    Comm::SetSelect(sock, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
 
     while (max--) {
         len = comm_udp_recvfrom(sock,
@@ -729,11 +730,7 @@ icpConnectionsOpen(void)
         if (theOutIcpConnection < 0)
             fatal("Cannot open Outgoing ICP Port");
 
-        commSetSelect(theOutIcpConnection,
-                      COMM_SELECT_READ,
-                      icpHandleUdp,
-                      NULL,
-                      0);
+        Comm::SetSelect(theOutIcpConnection, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
 
         debugs(12, 1, "Outgoing ICP messages on port " << addr.GetPort() << ", FD " << theOutIcpConnection << ".");
 
@@ -765,11 +762,7 @@ icpIncomingConnectionOpened(int fd, int errNo, Ip::Address& addr)
     if (theInIcpConnection < 0)
         fatal("Cannot open ICP Port");
 
-    commSetSelect(theInIcpConnection,
-                  COMM_SELECT_READ,
-                  icpHandleUdp,
-                  NULL,
-                  0);
+    Comm::SetSelect(theInIcpConnection, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
 
     for (const wordlist *s = Config.mcast_group_list; s; s = s->next)
         ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
@@ -815,7 +808,7 @@ icpConnectionShutdown(void)
      */
     assert(theOutIcpConnection > -1);
 
-    commSetSelect(theOutIcpConnection, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(theOutIcpConnection, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
 void
index d1f0fcf5e56ed6a314390875e33a92534ce9732f..59bf69b761b93d65633ce552ece020cc3cabe4c3 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "squid.h"
 #include "cbdata.h"
+#include "comm/Loops.h"
 #include "fde.h"
 #include "log/Config.h"
 #include "log/File.h"
@@ -151,7 +152,7 @@ logfileHandleWrite(int fd, void *data)
     /* there is, so schedule more */
 
 reschedule:
-    commSetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
+    Comm::SetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
     ll->flush_pending = 1;
 finish:
     return;
@@ -171,7 +172,7 @@ logfileQueueWrite(Logfile * lf)
             logfile_mod_daemon_append(lf, "F\n", 2);
     }
     /* Ok, schedule a write-event */
-    commSetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
+    Comm::SetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
 }
 
 static void
index d2fd0c1ec2a14b0523e7a868d3de80743cd92c11..662c6ef629720efee60853ef60c2d47689e33e4f 100644 (file)
@@ -42,6 +42,7 @@
 #if USE_DELAY_POOLS
 #include "ClientDelayConfig.h"
 #endif
+#include "comm.h"
 #include "ConfigParser.h"
 #include "CpuAffinity.h"
 #if USE_DELAY_POOLS
 #include "htcp.h"
 #include "StoreFileSystem.h"
 #include "DiskIO/DiskIOModule.h"
-#include "comm.h"
 #include "ipc/Kids.h"
 #include "ipc/Coordinator.h"
 #include "ipc/Strand.h"
 #include "ip/tools.h"
-#if USE_EPOLL
-#include "comm_epoll.h"
-#endif
-#if USE_KQUEUE
-#include "comm_kqueue.h"
-#endif
-#if USE_POLL
-#include "comm_poll.h"
-#endif
-#if defined(USE_SELECT) || defined(USE_SELECT_WIN32)
-#include "comm_select.h"
-#endif
 #include "SquidTime.h"
 #include "SwapDir.h"
 #include "forward.h"
@@ -1383,8 +1371,6 @@ SquidMain(int argc, char **argv)
 
     comm_init();
 
-    comm_select_init();
-
     mainInitialize();
 
     test_access();
@@ -1436,8 +1422,6 @@ SquidMain(int argc, char **argv)
     /* init comm module */
     comm_init();
 
-    comm_select_init();
-
     if (opt_no_daemon) {
         /* we have to init fdstat here. */
         fd_open(0, FD_LOG, "stdin");
index f3d13f89515f899a42f52b936e964ffe0c3a4117..555ee882ac5b578ea249e90614b6f8ccb427b3cf 100644 (file)
@@ -33,6 +33,7 @@
 #include "acl/FilledChecklist.h"
 #include "cache_snmp.h"
 #include "comm.h"
+#include "comm/Loops.h"
 #include "ipc/StartListening.h"
 #include "ip/Address.h"
 #include "ip/tools.h"
@@ -356,8 +357,7 @@ snmpIncomingConnectionOpened(int fd, int errNo)
     if (theInSnmpConnection < 0)
         fatal("Cannot open Incoming SNMP Port");
 
-    commSetSelect(theInSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL,
-                  0);
+    Comm::SetSelect(theInSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL, 0);
 
     debugs(1, 1, "Accepting SNMP messages on " << Config.Addrs.snmp_incoming <<
            ", FD " << theInSnmpConnection << ".");
@@ -373,8 +373,7 @@ snmpOutgoingConnectionOpened(int fd, int errNo)
     if (theOutSnmpConnection < 0)
         fatal("Cannot open Outgoing SNMP Port");
 
-    commSetSelect(theOutSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL,
-                  0);
+    Comm::SetSelect(theOutSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL, 0);
 
     debugs(1, 1, "Outgoing SNMP messages on " << Config.Addrs.snmp_outgoing <<
            ", FD " << theOutSnmpConnection << ".");
@@ -426,7 +425,7 @@ snmpConnectionShutdown(void)
      */
     assert(theOutSnmpConnection > -1);
 
-    commSetSelect(theOutSnmpConnection, COMM_SELECT_READ, NULL, NULL, 0);
+    Comm::SetSelect(theOutSnmpConnection, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
 void
@@ -459,7 +458,7 @@ snmpHandleUdp(int sock, void *not_used)
 
     debugs(49, 5, "snmpHandleUdp: Called.");
 
-    commSetSelect(sock, COMM_SELECT_READ, snmpHandleUdp, NULL, 0);
+    Comm::SetSelect(sock, COMM_SELECT_READ, snmpHandleUdp, NULL, 0);
 
     memset(buf, '\0', SNMP_REQUEST_SIZE);
 
index 45f8a8b906fce2da268ade94e9a680a219560682..a2007ae53819be29d9202261a4dc6be6b259edfe 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "squid.h"
 #include "comm.h"
+#include "comm/Loops.h"
 #include "CommRead.h"
 #include "fde.h"
 
@@ -90,14 +91,13 @@ commSetCloseOnExec(int fd)
 }
 
 void
-commSetSelect(int fd, unsigned int type, PF * handler, void *client_data,
-              time_t timeout)
+Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time_t timeout)
 {
     /* all test code runs synchronously at the moment */
 }
 
 void
-comm_quick_poll_required()
+Comm::QuickPollRequired()
 {
     /* for tests ... ignore */
 }
index 6e01a0824c7946acd63640beabe9ed8c40f4231a..fdad1a0a8229df7c5c5e374d73a071eb46bee60d 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
  *
  */
+#include "config.h"
+
+#if USE_WCCP
+
 #include "squid.h"
 #include "comm.h"
+#include "comm/Loops.h"
 #include "event.h"
 
-#if USE_WCCP
-
 #define WCCP_PORT 2048
 #define WCCP_REVISION 0
 #define WCCP_ACTIVE_CACHES 32
@@ -157,11 +160,7 @@ wccpConnectionOpen(void)
     if (theWccpConnection < 0)
         fatal("Cannot open WCCP Port");
 
-    commSetSelect(theWccpConnection,
-                  COMM_SELECT_READ,
-                  wccpHandleUdp,
-                  NULL,
-                  0);
+    Comm::SetSelect(theWccpConnection, COMM_SELECT_READ, wccpHandleUdp, NULL, 0);
 
     debugs(80, 1, "Accepting WCCPv1 messages on " << Config.Wccp.address << ", FD " << theWccpConnection << ".");
 
@@ -208,7 +207,7 @@ wccpHandleUdp(int sock, void *not_used)
 
     debugs(80, 6, "wccpHandleUdp: Called.");
 
-    commSetSelect(sock, COMM_SELECT_READ, wccpHandleUdp, NULL, 0);
+    Comm::SetSelect(sock, COMM_SELECT_READ, wccpHandleUdp, NULL, 0);
 
     memset(&wccp_i_see_you, '\0', sizeof(wccp_i_see_you));
 
index 6f49e7af4a23ce79cd2822b2fc73e1c04d54ffac..6e8cb568fde70c921e065469bbed9208e4f21239 100644 (file)
@@ -35,6 +35,7 @@
 #if USE_WCCPv2
 
 #include "comm.h"
+#include "comm/Loops.h"
 #include "compat/strsep.h"
 #include "event.h"
 #include "ip/Address.h"
@@ -1009,11 +1010,7 @@ wccp2ConnectionOpen(void)
     }
 
 #endif
-    commSetSelect(theWccp2Connection,
-                  COMM_SELECT_READ,
-                  wccp2HandleUdp,
-                  NULL,
-                  0);
+    Comm::SetSelect(theWccp2Connection, COMM_SELECT_READ, wccp2HandleUdp, NULL, 0);
 
     debugs(80, 1, "Accepting WCCPv2 messages on port " << WCCP_PORT << ", FD " << theWccp2Connection << ".");
     debugs(80, 1, "Initialising all WCCPv2 lists");
@@ -1174,7 +1171,7 @@ wccp2HandleUdp(int sock, void *not_used)
 
     debugs(80, 6, "wccp2HandleUdp: Called.");
 
-    commSetSelect(sock, COMM_SELECT_READ, wccp2HandleUdp, NULL, 0);
+    Comm::SetSelect(sock, COMM_SELECT_READ, wccp2HandleUdp, NULL, 0);
 
     /* FIXME INET6 : drop conversion boundary */
     Ip::Address from_tmp;