]> granicus.if.org Git - apache/commitdiff
don't poll if there is only a single listening socket
authorGreg Ames <gregames@apache.org>
Fri, 18 Jan 2002 22:31:50 +0000 (22:31 +0000)
committerGreg Ames <gregames@apache.org>
Fri, 18 Jan 2002 22:31:50 +0000 (22:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92916 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/prefork/prefork.c

index 6704c3379eeb8619ec9ef9fc19eb50cebde931ca..b8d1213bd3a79a419648d4fd3f14ed70d4830810 100644 (file)
@@ -644,31 +644,31 @@ static void child_main(int child_num_arg)
        /* Lock around "accept", if necessary */
        SAFE_ACCEPT(accept_mutex_on());
 
-       for (;;) {
-            apr_status_t ret;
-            apr_int16_t event;
-            apr_int32_t n;
-
-            ret = apr_poll(pollset, &n, -1);
-            if (ret != APR_SUCCESS) {
-                if (APR_STATUS_IS_EINTR(ret)) {
-                    continue;
-                }
-               /* Single Unix documents select as returning errnos
-                * EBADF, EINTR, and EINVAL... and in none of those
-                * cases does it make sense to continue.  In fact
-                * on Linux 2.0.x we seem to end up with EFAULT
-                * occasionally, and we'd loop forever due to it.
-                */
-               ap_log_error(APLOG_MARK, APLOG_ERR, ret, ap_server_conf,
+        if (num_listensocks == 1) {
+            offset = 0;
+        }
+        else {
+            /* multiple listening sockets - need to poll */
+           for (;;) {
+                apr_status_t ret;
+                apr_int16_t event;
+                apr_int32_t n;
+
+                ret = apr_poll(pollset, &n, -1);
+                if (ret != APR_SUCCESS) {
+                    if (APR_STATUS_IS_EINTR(ret)) {
+                        continue;
+                    }
+                   /* Single Unix documents select as returning errnos
+                    * EBADF, EINTR, and EINVAL... and in none of those
+                    * cases does it make sense to continue.  In fact
+                    * on Linux 2.0.x we seem to end up with EFAULT
+                    * occasionally, and we'd loop forever due to it.
+                    */
+                   ap_log_error(APLOG_MARK, APLOG_ERR, ret, ap_server_conf,
                              "apr_poll: (listen)");
-               clean_child_exit(1);
-            }
-            if (num_listensocks == 1) {
-                offset = 0;
-                goto got_fd;
-            }
-            else {
+                   clean_child_exit(1);
+                }
                 /* find a listener */
                 curr_pollfd = last_pollfd;
                 do {
@@ -684,9 +684,9 @@ static void child_main(int child_num_arg)
                         goto got_fd;
                     }
                 } while (curr_pollfd != last_pollfd);
-            }
 
-            continue;
+                continue;
+            }
         }
     got_fd:
        /* if we accept() something we don't want to die, so we have to