]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
* remove the do {} while (1); crap - we don't need it here
authoradrian <>
Sun, 27 Oct 2002 20:45:06 +0000 (20:45 +0000)
committeradrian <>
Sun, 27 Oct 2002 20:45:06 +0000 (20:45 +0000)
* fix the switch() statement and event handling - falling through is
  bad in this case as a registered event will only ever be a single
  type (unlike poll() where its a mask).

src/comm_kqueue.cc

index 32de27da7dcfcb7da674537241dc7966bccbabce..8ef663710929e36c35a7fa218dde95ffa396e826 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_kqueue.cc,v 1.4 2002/10/27 13:06:49 adrian Exp $
+ * $Id: comm_kqueue.cc,v 1.5 2002/10/27 13:45:06 adrian Exp $
  *
  * DEBUG: section 5    Socket functions
  *
@@ -225,62 +225,60 @@ comm_select(int msec)
     static struct kevent ke[KE_LENGTH];
     struct timespec poll_time;
 
-    do {
-        /*
-         * remember we are doing NANOseconds here, not micro/milli. God knows
-         * why jlemon used a timespec, but hey, he wrote the interface, not I
-         *   -- Adrian
-         */
-        poll_time.tv_sec = msec / 1000;
-        poll_time.tv_nsec = (msec % 1000) * 1000000;
-        for (;;) {
-            num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time);
-            statCounter.select_loops++;
-            kqoff = 0;
-            if (num >= 0)
-                break;
-            if (ignoreErrno(errno))
-                break;
-            getCurrentTime();
-            return COMM_ERROR;
-            /* NOTREACHED */
-        }
-
+    /*
+     * remember we are doing NANOseconds here, not micro/milli. God knows
+     * why jlemon used a timespec, but hey, he wrote the interface, not I
+     *   -- Adrian
+     */
+    poll_time.tv_sec = msec / 1000;
+    poll_time.tv_nsec = (msec % 1000) * 1000000;
+    for (;;) {
+        num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time);
+        statCounter.select_loops++;
+        kqoff = 0;
+        if (num >= 0)
+            break;
+        if (ignoreErrno(errno))
+            break;
         getCurrentTime();
-        if (num == 0)
-            continue;
-
-        for (i = 0; i < num; i++) {
-            int fd = (int) ke[i].ident;
-            PF *hdl = NULL;
-            fde *F = &fd_table[fd];
-
-            if (ke[i].flags & EV_ERROR) {
-                errno = ke[i].data;
-                /* XXX error == bad! -- adrian */
-                continue;        /* XXX! */
-            }
-            switch (ke[i].filter) {
+        return COMM_ERROR;
+        /* NOTREACHED */
+    }
+
+    getCurrentTime();
+    if (num == 0)
+        continue;
+
+    for (i = 0; i < num; i++) {
+        int fd = (int) ke[i].ident;
+        PF *hdl = NULL;
+        fde *F = &fd_table[fd];
+
+        if (ke[i].flags & EV_ERROR) {
+            errno = ke[i].data;
+            /* XXX error == bad! -- adrian */
+            continue;        /* XXX! */
+        }
+        switch (ke[i].filter) {
             case EVFILT_READ:
                 if ((hdl = F->read_handler) != NULL) {
                     F->read_handler = NULL;
                     hdl(fd, F->read_data);
                 }
+               break;
             case EVFILT_WRITE:
                 if ((hdl = F->write_handler) != NULL) {
                     F->write_handler = NULL;
                     hdl(fd, F->write_data);
                 }
+               break;
             default:
                 /* Bad! -- adrian */
+               debug(5, 1) ("comm_select: kevent returned %d!\n", fe[i].filter);
                 break;
-            }
         }
-        return COMM_OK;
     }
-    while (0);                        /* XXX should rip this out! -- adrian */
-    /* XXX Get here, we broke! */
-    return 0;
+    return COMM_OK;
 }
 
 #endif /* USE_KQUEUE */