]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/comm/ModDevPoll.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / comm / ModDevPoll.cc
index 8db2585e74d40c90411cecac4509d2038e695f42..e9ba660c125cddd6dbf92621c66092ff5e31bcad 100644 (file)
  * modules from creating several versions of the same function simultaneously.
  */
 
-#include "config.h"
+#include "squid.h"
 
 #if USE_DEVPOLL
 
-#include "squid.h"
 #include "comm/Loops.h"
 #include "fde.h"
 #include "mgr/Registration.h"
+#include "profiler/Profiler.h"
 #include "SquidTime.h"
+#include "StatCounters.h"
+#include "StatHist.h"
 #include "Store.h"
 
 #if HAVE_SYS_DEVPOLL_H
 /* Solaris /dev/poll support, see "man -s 7D poll" */
 #include <sys/devpoll.h>
 #endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
 #define DEBUG_DEVPOLL 0
 
@@ -95,7 +100,6 @@ static struct {
     int size; /**< maximum number of elements in array */
 } devpoll_update;
 
-
 /* STATIC VARIABLES */
 static int devpoll_fd; /**< handle to /dev/poll device */
 static int max_poll_time = 1000; /**< maximum milliseconds to spend in poll */
@@ -107,7 +111,6 @@ static int dpoll_nfds; /**< maximum number of poll results */
 /* PROTOTYPES */
 static void commDevPollRegisterWithCacheManager(void);
 
-
 /* PRIVATE FUNCTIONS */
 /** \brief Write batched file descriptor event changes to poll device
  *
@@ -163,22 +166,19 @@ comm_update_fd(int fd, int events)
         comm_flush_updates();
 
     /* Push new event onto array */
-    devpoll_update.cur++;
+    ++ devpoll_update.cur;
     devpoll_update.pfds[devpoll_update.cur].fd = fd;
     devpoll_update.pfds[devpoll_update.cur].events = events;
     devpoll_update.pfds[devpoll_update.cur].revents = 0;
 }
 
-
 static void commIncomingStats(StoreEntry *sentry)
 {
-    StatCounters *f = &statCounter;
     storeAppendPrintf(sentry, "Total number of devpoll loops: %ld\n", statCounter.select_loops);
     storeAppendPrintf(sentry, "Histogram of returned filedescriptors\n");
-    statHistDump(&f->select_fds_hist, sentry, statHistIntDumper);
+    statCounter.select_fds_hist.dump(sentry, statHistIntDumper);
 }
 
-
 static void
 commDevPollRegisterWithCacheManager(void)
 {
@@ -191,7 +191,6 @@ commDevPollRegisterWithCacheManager(void)
     );
 }
 
-
 /* PUBLIC FUNCTIONS */
 
 /** \brief Initialise /dev/poll support
@@ -315,7 +314,6 @@ Comm::SetSelect(int fd, unsigned int type, PF * handler, void *client_data, time
         F->timeout = squid_curtime + timeout;
 }
 
-
 /** \brief Clear polling of file handle (both read and write)
  *
  * @param fd file descriptor to clear polling on
@@ -327,7 +325,6 @@ Comm::ResetSelect(int fd)
     SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
 }
 
-
 /** \brief Do poll and trigger callback functions as appropriate
  *
  * Check all connections for new connections and input data that is to be
@@ -360,7 +357,7 @@ Comm::DoSelect(int msec)
         comm_flush_updates(); /* ensure latest changes are sent to /dev/poll */
 
         num = ioctl(devpoll_fd, DP_POLL, &do_poll);
-        ++statCounter.select_loops;
+        ++ statCounter.select_loops;
 
         if (num >= 0)
             break; /* no error, skip out of loop */
@@ -377,14 +374,14 @@ Comm::DoSelect(int msec)
     PROF_stop(comm_check_incoming);
     getCurrentTime();
 
-    statHistCount(&statCounter.select_fds_hist, num);
+    statCounter.select_fds_hist.count(num);
 
     if (num == 0)
         return COMM_TIMEOUT; /* no error */
 
     PROF_start(comm_handle_ready_fd);
 
-    for (i = 0; i < num; i++) {
+    for (i = 0; i < num; ++i) {
         int fd = (int)do_poll.dp_fds[i].fd;
         F = &fd_table[fd];
         debugs(
@@ -420,7 +417,7 @@ Comm::DoSelect(int msec)
                 F->read_handler = NULL;
                 hdl(fd, F->read_data);
                 PROF_stop(comm_read_handler);
-                statCounter.select_fds++;
+                ++ statCounter.select_fds;
             } else {
                 debugs(
                     5,
@@ -444,7 +441,7 @@ Comm::DoSelect(int msec)
                 F->write_handler = NULL;
                 hdl(fd, F->write_data);
                 PROF_stop(comm_write_handler);
-                statCounter.select_fds++;
+                ++ statCounter.select_fds;
             } else {
                 debugs(
                     5,