Blame SOURCES/httpd-2.4.6-ap-ipv6.patch

f0c688
diff --git a/support/ab.c b/support/ab.c
f0c688
index f54c402..93c9066 100644
f0c688
--- a/support/ab.c
f0c688
+++ b/support/ab.c
f0c688
@@ -344,6 +344,7 @@ apr_time_t start, lasttime, stoptime;
f0c688
 char _request[8192];
f0c688
 char *request = _request;
f0c688
 apr_size_t reqlen;
f0c688
+int requests_initialized = 0;
f0c688
 
f0c688
 /* one global throw-away buffer to read stuff into */
f0c688
 char buffer[8192];
f0c688
@@ -1253,12 +1254,18 @@ static void start_connect(struct connection * c)
f0c688
         else {
f0c688
             set_conn_state(c, STATE_UNCONNECTED);
f0c688
             apr_socket_close(c->aprsock);
f0c688
-            err_conn++;
f0c688
-            if (bad++ > 10) {
f0c688
+            if (good == 0 && destsa->next) {
f0c688
+                destsa = destsa->next;
f0c688
+                err_conn = 0;
f0c688
+            }
f0c688
+            else if (bad++ > 10) {
f0c688
                 fprintf(stderr,
f0c688
                    "\nTest aborted after 10 failures\n\n");
f0c688
                 apr_err("apr_socket_connect()", rv);
f0c688
             }
f0c688
+            else {
f0c688
+                err_conn++;
f0c688
+            }
f0c688
 
f0c688
             start_connect(c);
f0c688
             return;
f0c688
@@ -1339,6 +1346,7 @@ static void read_connection(struct connection * c)
f0c688
     apr_status_t status;
f0c688
     char *part;
f0c688
     char respcode[4];       /* 3 digits and null */
f0c688
+    int i;
f0c688
 
f0c688
     r = sizeof(buffer);
f0c688
 #ifdef USE_SSL
f0c688
@@ -1362,6 +1370,13 @@ static void read_connection(struct connection * c)
f0c688
                 good++;
f0c688
                 close_connection(c);
f0c688
             }
f0c688
+            else if (scode == SSL_ERROR_SYSCALL 
f0c688
+                     && c->read == 0
f0c688
+                     && destsa->next
f0c688
+                     && c->state == STATE_CONNECTING
f0c688
+                     && good == 0) {
f0c688
+                return;
f0c688
+            }
f0c688
             else if (scode != SSL_ERROR_WANT_WRITE
f0c688
                      && scode != SSL_ERROR_WANT_READ) {
f0c688
                 /* some fatal error: */
f0c688
@@ -1387,8 +1402,8 @@ static void read_connection(struct connection * c)
f0c688
         }
f0c688
         /* catch legitimate fatal apr_socket_recv errors */
f0c688
         else if (status != APR_SUCCESS) {
f0c688
-            err_recv++;
f0c688
             if (recverrok) {
f0c688
+                err_recv++;
f0c688
                 bad++;
f0c688
                 close_connection(c);
f0c688
                 if (verbosity >= 1) {
f0c688
@@ -1396,7 +1411,12 @@ static void read_connection(struct connection * c)
f0c688
                     fprintf(stderr,"%s: %s (%d)\n", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status);
f0c688
                 }
f0c688
                 return;
f0c688
-            } else {
f0c688
+            } else if (destsa->next && c->state == STATE_CONNECTING
f0c688
+                       && c->read == 0 && good == 0) {
f0c688
+                return;
f0c688
+            }
f0c688
+            else {
f0c688
+                err_recv++;
f0c688
                 apr_err("apr_socket_recv", status);
f0c688
             }
f0c688
         }
f0c688
@@ -1523,6 +1543,16 @@ static void read_connection(struct connection * c)
f0c688
             }
f0c688
             c->bread += c->cbx - (s + l - c->cbuff) + r - tocopy;
f0c688
             totalbread += c->bread;
f0c688
+
f0c688
+            /* We have received the header, so we know this destination socket
f0c688
+             * address is working, so initialize all remaining requests. */
f0c688
+            if (!requests_initialized) {
f0c688
+                for (i = 1; i < concurrency; i++) {
f0c688
+                    con[i].socknum = i;
f0c688
+                    start_connect(&con[i]);
f0c688
+                }
f0c688
+                requests_initialized = 1;
f0c688
+            }
f0c688
         }
f0c688
     }
f0c688
     else {
f0c688
@@ -1734,11 +1764,10 @@ static void test(void)
f0c688
     apr_signal(SIGINT, output_results);
f0c688
 #endif
f0c688
 
f0c688
-    /* initialise lots of requests */
f0c688
-    for (i = 0; i < concurrency; i++) {
f0c688
-        con[i].socknum = i;
f0c688
-        start_connect(&con[i]);
f0c688
-    }
f0c688
+    /* initialise first connection to determine destination socket address
f0c688
+     * which should be used for next connections. */
f0c688
+    con[0].socknum = 0;
f0c688
+    start_connect(&con[0]);
f0c688
 
f0c688
     do {
f0c688
         apr_int32_t n;
f0c688
@@ -1786,14 +1815,20 @@ static void test(void)
f0c688
             if ((rtnev & APR_POLLIN) || (rtnev & APR_POLLPRI) || (rtnev & APR_POLLHUP))
f0c688
                 read_connection(c);
f0c688
             if ((rtnev & APR_POLLERR) || (rtnev & APR_POLLNVAL)) {
f0c688
-                bad++;
f0c688
-                err_except++;
f0c688
-                /* avoid apr_poll/EINPROGRESS loop on HP-UX, let recv discover ECONNREFUSED */
f0c688
-                if (c->state == STATE_CONNECTING) {
f0c688
-                    read_connection(c);
f0c688
+                if (destsa->next && c->state == STATE_CONNECTING && good == 0) {
f0c688
+                    destsa = destsa->next;
f0c688
+                    start_connect(c);
f0c688
                 }
f0c688
                 else {
f0c688
-                    start_connect(c);
f0c688
+                    bad++;
f0c688
+                    err_except++;
f0c688
+                    /* avoid apr_poll/EINPROGRESS loop on HP-UX, let recv discover ECONNREFUSED */
f0c688
+                    if (c->state == STATE_CONNECTING) {
f0c688
+                        read_connection(c);
f0c688
+                    }
f0c688
+                    else {
f0c688
+                        start_connect(c);
f0c688
+                    }
f0c688
                 }
f0c688
                 continue;
f0c688
             }