From: Aaron Bannert Date: Wed, 24 Apr 2002 17:09:59 +0000 (+0000) Subject: Major improvement in concurrent processing for AB: X-Git-Tag: 2.0.36~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b19a402e7a4d6254c44a13781e5ffc3efa31234;p=apache Major improvement in concurrent processing for AB: - 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 --- diff --git a/support/ab.c b/support/ab.c index 16987cf367..4e65894ac6 100644 --- a/support/ab.c +++ b/support/ab.c @@ -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("

\n"); - printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AP_SERVER_BASEREVISION, "$Revision: 1.95 $"); + printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AP_SERVER_BASEREVISION, "$Revision: 1.96 $"); 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

\n");