]> granicus.if.org Git - apache/commitdiff
Major improvement in concurrent processing for AB:
authorAaron Bannert <aaron@apache.org>
Wed, 24 Apr 2002 17:09:59 +0000 (17:09 +0000)
committerAaron Bannert <aaron@apache.org>
Wed, 24 Apr 2002 17:09:59 +0000 (17:09 +0000)
- Enable non-blocking connects.
- Prevent quasi-blocking mode apr_recv (which would prevent AB from
  multiplexing over the entire descriptor set).
- Catch other fatal apr_recv() errors.

[This patch is slightly different than the one posted to the dev list,
but regardless thanks to the many people who reviewed this.]

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

support/ab.c

index 16987cf367d8f41ab96e18cfa71c1a3e3ea4a3d6..4e65894ac65634af0c49abb41b478df8a265ed4e 100644 (file)
@@ -853,6 +853,10 @@ static void start_connect(struct connection * c)
                                SOCK_STREAM, c->ctx)) != APR_SUCCESS) {
        apr_err("socket", rv);
     }
+    if ((rv = apr_setsocketopt(c->aprsock, APR_SO_NONBLOCK, 1))
+         != APR_SUCCESS) {
+        apr_err("socket nonblock", rv);
+    }
     c->start = apr_time_now();
     if ((rv = apr_connect(c->aprsock, destsa)) != APR_SUCCESS) {
        if (APR_STATUS_IS_EINPROGRESS(rv)) {
@@ -941,16 +945,21 @@ static void read_connection(struct connection * c)
     char respcode[4];          /* 3 digits and null */
 
     r = sizeof(buffer);
-    apr_setsocketopt(c->aprsock, APR_SO_TIMEOUT, aprtimeout);
     status = apr_recv(c->aprsock, buffer, &r);
-    if (r == 0 || (status != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(status))) {
+    if (APR_STATUS_IS_EAGAIN(status))
+       return;
+    else if (r == 0 && APR_STATUS_IS_EOF(status)) {
        good++;
        close_connection(c);
        return;
     }
-
-    if (APR_STATUS_IS_EAGAIN(status))
-       return;
+    /* catch legitimate fatal apr_recv errors */
+    else if (status != APR_SUCCESS) {
+        err_except++; /* XXX: is this the right error counter? */
+        /* XXX: Should errors here be fatal, or should we allow a
+         * certain number of them before completely failing? -aaron */
+        apr_err("apr_recv", status);
+    }
 
     totalread += r;
     if (c->read == 0) {
@@ -1302,14 +1311,14 @@ static void test(void)
 static void copyright(void)
 {
     if (!use_html) {
-       printf("This is ApacheBench, Version %s\n", AP_SERVER_BASEREVISION " <$Revision: 1.95 $> apache-2.0");
+       printf("This is ApacheBench, Version %s\n", AP_SERVER_BASEREVISION " <$Revision: 1.96 $> apache-2.0");
        printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
        printf("Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/\n");
        printf("\n");
     }
     else {
        printf("<p>\n");
-       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AP_SERVER_BASEREVISION, "$Revision: 1.95 $");
+       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AP_SERVER_BASEREVISION, "$Revision: 1.96 $");
        printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
        printf(" Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/<br>\n");
        printf("</p>\n<p>\n");