]> granicus.if.org Git - apache/commitdiff
Fix a couple of problems associated with recognizing when file
authorJeff Trawick <trawick@apache.org>
Fri, 23 Jun 2000 20:23:08 +0000 (20:23 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 23 Jun 2000 20:23:08 +0000 (20:23 +0000)
descriptors for connected sockets are too big.

Todo: The BeOS MPMs seem to have the same issue.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85679 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/dexter/dexter.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c

index 198859817713451f97e9ce54e2df8d67d8e62ac5..87a62c0f0a39e9805ef1e60fed8cf71386627da9 100644 (file)
@@ -497,24 +497,19 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id)
     if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock");
     }
-    sock_disable_nagle(csd);
 
-    iol = unix_attach_socket(sock);
-    if (iol == NULL) {
-        if (errno == EBADF) {
-            ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, NULL,
-                "filedescriptor (%u) larger than FD_SETSIZE (%u) "
-                "found, you probably need to rebuild Apache with a "
-                "larger FD_SETSIZE", csd, FD_SETSIZE);
-        }
-        else {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
-                "error attaching to socket");
-        }
+    if (csd >= FD_SETSIZE) {
+        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
+                     "new file descriptor %d is too large; you probably need "
+                     "to rebuild Apache with a larger FD_SETSIZE "
+                     "(currently %d)", 
+                     csd, FD_SETSIZE);
         ap_close_socket(sock);
-       return;
+        return;
     }
 
+    sock_disable_nagle(csd);
+    iol = unix_attach_socket(sock);
     conn_io = ap_bcreate(p, B_RDWR);
     ap_bpush_iol(conn_io, iol);
 
index 72abaa5e92d647d832a0197a1a85c4d9afabba55..f4aa7a92e12afd49bc32d9af9a4376f692679b29 100644 (file)
@@ -492,23 +492,19 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in
 
     (void) ap_get_os_sock(&csd, sock);
 
+    if (csd >= FD_SETSIZE) {
+        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
+                     "new file descriptor %d is too large; you probably need "
+                     "to rebuild Apache with a larger FD_SETSIZE "
+                     "(currently %d)", 
+                     csd, FD_SETSIZE);
+        ap_close_socket(sock);
+        return;
+    }
+
     sock_disable_nagle(csd);
 
     iol = unix_attach_socket(sock);
-    if (iol == NULL) {
-        if (errno == EBADF) {
-            ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
-                "filedescriptor (%u) larger than FD_SETSIZE (%u) "
-                "found, you probably need to rebuild Apache with a "
-                "larger FD_SETSIZE", csd, FD_SETSIZE);
-        }
-        else {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
-                "error attaching to socket");
-        }
-        ap_close_socket(sock);
-       return;
-    }
 
     (void) ap_update_child_status(my_child_num, my_thread_num,  
                                  SERVER_BUSY_READ, (request_rec *) NULL);
index d27be5b0e13ad946b13fdb4bb6dc61016e19d9d6..107238da033ebf25b8c4d68676a0c70656b8f28c 100644 (file)
@@ -1003,11 +1003,6 @@ static void child_main(int child_num_arg)
 
        SAFE_ACCEPT(accept_mutex_off());        /* unlock after "accept" */
 
-#ifdef TPF
-       if (csd == 0)                       /* 0 is invalid socket for TPF */
-           continue;
-#endif
-
        /* We've got a socket, let's at least process one request off the
         * socket before we accept a graceful restart request.  We set
         * the signal to ignore because we don't want to disturb any
@@ -1021,24 +1016,24 @@ static void child_main(int child_num_arg)
 
         ap_get_os_sock(&sockdes, csd);
 
-       sock_disable_nagle(sockdes);
-
-       iol = unix_attach_socket(csd);
-       if (iol == NULL) {
-           if (errno == EBADF) {
-               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
-                   "filedescriptor (%u) larger than FD_SETSIZE (%u) "
-                   "found, you probably need to rebuild Apache with a "
-                   "larger FD_SETSIZE", sockdes, FD_SETSIZE);
-           }
-           else {
-               ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
-                   "error attaching to socket");
-           }
+        if (sockdes >= FD_SETSIZE) {
+            ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
+                         "new file descriptor %d is too large; you probably need "
+                         "to rebuild Apache with a larger FD_SETSIZE "
+                         "(currently %d)", 
+                         sockdes, FD_SETSIZE);
            ap_close_socket(csd);
            continue;
-       }
+        }
 
+#ifdef TPF
+       if (sockdes == 0)                   /* 0 is invalid socket for TPF */
+           continue;
+#endif
+
+       sock_disable_nagle(sockdes);
+
+       iol = unix_attach_socket(csd);
        (void) ap_update_child_status(my_child_num, SERVER_BUSY_READ,
                                   (request_rec *) NULL);