From 430892c1abdcc388e056a81f7117f0c20d7d6638 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kalu=C5=BEa?= Date: Tue, 30 Sep 2014 10:39:41 +0000 Subject: [PATCH] ab: Use only one connection to determine working destination socket address. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1628388 13f79535-47bb-0310-9956-ffa450edef68 --- support/ab.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/support/ab.c b/support/ab.c index 095e3d03a7..a4599dc30c 100644 --- a/support/ab.c +++ b/support/ab.c @@ -343,6 +343,7 @@ apr_time_t start, lasttime, stoptime; char _request[8192]; char *request = _request; apr_size_t reqlen; +int requests_initialized = 0; /* one global throw-away buffer to read stuff into */ char buffer[8192]; @@ -1395,6 +1396,7 @@ static void read_connection(struct connection * c) apr_status_t status; char *part; char respcode[4]; /* 3 digits and null */ + int i; r = sizeof(buffer); #ifdef USE_SSL @@ -1593,6 +1595,16 @@ static void read_connection(struct connection * c) } c->bread += c->cbx - (s + l - c->cbuff) + r - tocopy; totalbread += c->bread; + + /* We have received the header, so we know this destination socket + * address is working, so initialize all remaining requests. */ + if (!requests_initialized) { + for (i = 1; i < concurrency; i++) { + con[i].socknum = i; + start_connect(&con[i]); + } + requests_initialized = 1; + } } } else { @@ -1797,11 +1809,10 @@ static void test(void) apr_signal(SIGINT, output_results); #endif - /* initialise lots of requests */ - for (i = 0; i < concurrency; i++) { - con[i].socknum = i; - start_connect(&con[i]); - } + /* initialise first connection to determine destination socket address + * which should be used for next connections. */ + con[0].socknum = 0; + start_connect(&con[0]); do { apr_int32_t n; -- 2.40.0