]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
changed postinc to preinc operators and increased readability in ModSelect.cc
authorFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 6 Jul 2012 12:19:11 +0000 (14:19 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 6 Jul 2012 12:19:11 +0000 (14:19 +0200)
src/comm/ModSelect.cc

index c4b7188e6ecedb92f4defe3807b6518edf95d79a..b1346e08dcf311c8514394d13a91334c78f97732 100644 (file)
@@ -215,7 +215,7 @@ comm_check_incoming_select_handlers(int nfds, int *fds)
     FD_ZERO(&write_mask);
     incoming_sockets_accepted = 0;
 
-    for (i = 0; i < nfds; i++) {
+    for (i = 0; i < nfds; ++i) {
         fd = fds[i];
 
         if (fd_table[fd].read_handler) {
@@ -238,7 +238,7 @@ comm_check_incoming_select_handlers(int nfds, int *fds)
 
     getCurrentTime();
 
-    ++statCounter.syscalls.selects;
+    ++ statCounter.syscalls.selects;
 
     if (select(maxfd, &read_mask, &write_mask, NULL, &zero_tv) < 1)
         return incoming_sockets_accepted;
@@ -278,11 +278,15 @@ comm_select_udp_incoming(void)
     int nevents;
     udp_io_events = 0;
 
-    if (Comm::IsConnOpen(icpIncomingConn))
-        fds[nfds++] = icpIncomingConn->fd;
+    if (Comm::IsConnOpen(icpIncomingConn)) {
+        fds[nfds] = icpIncomingConn->fd;
+        ++nfds;
+    }
 
-    if (Comm::IsConnOpen(icpOutgoingConn) && icpIncomingConn != icpOutgoingConn)
-        fds[nfds++] = icpOutgoingConn->fd;
+    if (Comm::IsConnOpen(icpOutgoingConn) && icpIncomingConn != icpOutgoingConn) {
+        fds[nfds] = icpOutgoingConn->fd;
+        ++nfds;
+    }
 
     if (nfds == 0)
         return;
@@ -314,8 +318,10 @@ comm_select_tcp_incoming(void)
     // XXX: only poll sockets that won't be deferred. But how do we identify them?
 
     for (const AnyP::PortCfg *s = Config.Sockaddr.http; s; s = s->next) {
-        if (Comm::IsConnOpen(s->listenConn))
-            fds[nfds++] = s->listenConn->fd;
+        if (Comm::IsConnOpen(s->listenConn)) {
+            fds[nfds] = s->listenConn->fd;
+            ++nfds;
+        }
     }
 
     nevents = comm_check_incoming_select_handlers(nfds, fds);
@@ -397,11 +403,11 @@ Comm::DoSelect(int msec)
 
         fdsp = (fd_mask *) & readfds;
 
-        for (j = 0; j < maxindex; j++) {
+        for (j = 0; j < maxindex; ++j) {
             if ((tmask = fdsp[j]) == 0)
                 continue;      /* no bits here */
 
-            for (k = 0; k < FD_MASK_BITS; k++) {
+            for (k = 0; k < FD_MASK_BITS; ++k) {
                 if (!EBIT_TEST(tmask, k))
                     continue;
 
@@ -410,13 +416,13 @@ Comm::DoSelect(int msec)
 
                 if (FD_ISSET(fd, &readfds) && fd_table[fd].flags.read_pending) {
                     FD_SET(fd, &pendingfds);
-                    pending++;
+                    ++pending;
                 }
             }
         }
 
 #if DEBUG_FDBITS
-        for (i = 0; i < maxfd; i++) {
+        for (i = 0; i < maxfd; ++i) {
             /* Check each open socket for a handler. */
 
             if (fd_table[i].read_handler) {
@@ -443,9 +449,9 @@ Comm::DoSelect(int msec)
         for (;;) {
             poll_time.tv_sec = msec / 1000;
             poll_time.tv_usec = (msec % 1000) * 1000;
-            statCounter.syscalls.selects++;
+            ++ statCounter.syscalls.selects;
             num = select(maxfd, &readfds, &writefds, NULL, &poll_time);
-            ++statCounter.select_loops;
+            ++ statCounter.select_loops;
 
             if (num >= 0 || pending > 0)
                 break;
@@ -481,11 +487,11 @@ Comm::DoSelect(int msec)
 
         maxindex = howmany(maxfd, FD_MASK_BITS);
 
-        for (j = 0; j < maxindex; j++) {
+        for (j = 0; j < maxindex; ++j) {
             if ((tmask = (fdsp[j] | pfdsp[j])) == 0)
                 continue;      /* no bits here */
 
-            for (k = 0; k < FD_MASK_BITS; k++) {
+            for (k = 0; k < FD_MASK_BITS; ++k) {
                 if (tmask == 0)
                     break;     /* no more bits left */
 
@@ -530,7 +536,7 @@ Comm::DoSelect(int msec)
                     F->flags.read_pending = 0;
                     commUpdateReadBits(fd, NULL);
                     hdl(fd, F->read_data);
-                    statCounter.select_fds++;
+                    ++ statCounter.select_fds;
 
                     if (commCheckUdpIncoming)
                         comm_select_udp_incoming();
@@ -546,11 +552,11 @@ Comm::DoSelect(int msec)
 
         fdsp = (fd_mask *) & writefds;
 
-        for (j = 0; j < maxindex; j++) {
+        for (j = 0; j < maxindex; ++j) {
             if ((tmask = fdsp[j]) == 0)
                 continue;      /* no bits here */
 
-            for (k = 0; k < FD_MASK_BITS; k++) {
+            for (k = 0; k < FD_MASK_BITS; ++k) {
                 if (tmask == 0)
                     break;     /* no more bits left */
 
@@ -592,7 +598,7 @@ Comm::DoSelect(int msec)
                     F->write_handler = NULL;
                     commUpdateWriteBits(fd, NULL);
                     hdl(fd, F->write_data);
-                    statCounter.select_fds++;
+                    ++ statCounter.select_fds;
 
                     if (commCheckUdpIncoming)
                         comm_select_udp_incoming();
@@ -637,11 +643,15 @@ comm_select_dns_incoming(void)
     if (DnsSocketA < 0 && DnsSocketB < 0)
         return;
 
-    if (DnsSocketA >= 0)
-        fds[nfds++] = DnsSocketA;
+    if (DnsSocketA >= 0) {
+        fds[nfds] = DnsSocketA;
+        ++nfds;
+    }
 
-    if (DnsSocketB >= 0)
-        fds[nfds++] = DnsSocketB;
+    if (DnsSocketB >= 0) {
+        fds[nfds] = DnsSocketB;
+        ++nfds;
+    }
 
     nevents = comm_check_incoming_select_handlers(nfds, fds);
 
@@ -700,7 +710,7 @@ examine_select(fd_set * readfds, fd_set * writefds)
     struct stat sb;
     debugs(5, 0, "examine_select: Examining open file descriptors...");
 
-    for (fd = 0; fd < Squid_MaxFD; fd++) {
+    for (fd = 0; fd < Squid_MaxFD; ++fd) {
         FD_ZERO(&read_x);
         FD_ZERO(&write_x);
         tv.tv_sec = tv.tv_usec = 0;
@@ -712,7 +722,7 @@ examine_select(fd_set * readfds, fd_set * writefds)
         else
             continue;
 
-        statCounter.syscalls.selects++;
+        ++ statCounter.syscalls.selects;
         errno = 0;
 
         if (!fstat(fd, &sb)) {
@@ -772,10 +782,10 @@ commUpdateReadBits(int fd, PF * handler)
 {
     if (handler && !FD_ISSET(fd, &global_readfds)) {
         FD_SET(fd, &global_readfds);
-        nreadfds++;
+        ++nreadfds;
     } else if (!handler && FD_ISSET(fd, &global_readfds)) {
         FD_CLR(fd, &global_readfds);
-        nreadfds--;
+        --nreadfds;
     }
 }
 
@@ -784,10 +794,10 @@ commUpdateWriteBits(int fd, PF * handler)
 {
     if (handler && !FD_ISSET(fd, &global_writefds)) {
         FD_SET(fd, &global_writefds);
-        nwritefds++;
+        ++nwritefds;
     } else if (!handler && FD_ISSET(fd, &global_writefds)) {
         FD_CLR(fd, &global_writefds);
-        nwritefds--;
+        --nwritefds;
     }
 }