From 79a053210004c2a1098bae4f81f02c9300ac6bcf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kalu=C5=BEa?= Date: Tue, 23 Sep 2014 07:12:54 +0000 Subject: [PATCH] ab: try all destination socket addresses returned by apr_sockaddr_info_get instead of failing on first one when not available. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1626956 13f79535-47bb-0310-9956-ffa450edef68 --- support/ab.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/support/ab.c b/support/ab.c index 1bcab1bbbd..095e3d03a7 100644 --- a/support/ab.c +++ b/support/ab.c @@ -1303,12 +1303,18 @@ static void start_connect(struct connection * c) else { set_conn_state(c, STATE_UNCONNECTED); apr_socket_close(c->aprsock); - err_conn++; - if (bad++ > 10) { + if (good == 0 && destsa->next) { + destsa = destsa->next; + err_conn = 0; + } + else if (bad++ > 10) { fprintf(stderr, "\nTest aborted after 10 failures\n\n"); apr_err("apr_socket_connect()", rv); } + else { + err_conn++; + } start_connect(c); return; @@ -1412,6 +1418,13 @@ static void read_connection(struct connection * c) good++; close_connection(c); } + else if (scode == SSL_ERROR_SYSCALL + && c->read == 0 + && destsa->next + && c->state == STATE_CONNECTING + && good == 0) { + return; + } else if (scode != SSL_ERROR_WANT_WRITE && scode != SSL_ERROR_WANT_READ) { /* some fatal error: */ @@ -1437,8 +1450,8 @@ static void read_connection(struct connection * c) } /* catch legitimate fatal apr_socket_recv errors */ else if (status != APR_SUCCESS) { - err_recv++; if (recverrok) { + err_recv++; bad++; close_connection(c); if (verbosity >= 1) { @@ -1446,7 +1459,12 @@ static void read_connection(struct connection * c) fprintf(stderr,"%s: %s (%d)\n", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status); } return; - } else { + } else if (destsa->next && c->state == STATE_CONNECTING + && c->read == 0 && good == 0) { + return; + } + else { + err_recv++; apr_err("apr_socket_recv", status); } } @@ -1831,14 +1849,20 @@ static void test(void) if ((rtnev & APR_POLLIN) || (rtnev & APR_POLLPRI) || (rtnev & APR_POLLHUP)) read_connection(c); if ((rtnev & APR_POLLERR) || (rtnev & APR_POLLNVAL)) { - bad++; - err_except++; - /* avoid apr_poll/EINPROGRESS loop on HP-UX, let recv discover ECONNREFUSED */ - if (c->state == STATE_CONNECTING) { - read_connection(c); + if (destsa->next && c->state == STATE_CONNECTING && good == 0) { + destsa = destsa->next; + start_connect(c); } else { - start_connect(c); + bad++; + err_except++; + /* avoid apr_poll/EINPROGRESS loop on HP-UX, let recv discover ECONNREFUSED */ + if (c->state == STATE_CONNECTING) { + read_connection(c); + } + else { + start_connect(c); + } } continue; } -- 2.40.0