From: Jeff Trawick Date: Thu, 8 Mar 2007 21:00:07 +0000 (+0000) Subject: ab: Add -r option to continue after socket receive errors. X-Git-Tag: 2.3.0~1885 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91cdb74329a96135ba7c4701dddb3801302650a7;p=thirdparty%2Fapache%2Fhttpd.git ab: Add -r option to continue after socket receive errors. Submitted by: Filip Hanik Reviewed by: trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@516175 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 46e3f5083a5..bd4bd1cb6fe 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) ab: Add -r option to continue after socket receive errors. + [Filip Hanik ] + *) mod_ldap: Fix the search limit parameter to ldap_search_ext_s() for SDKs that define LDAP_NO_LIMIT to something other than -1. [David Jones ] diff --git a/support/ab.c b/support/ab.c index 14ee7ff6499..37bcb8a4a7a 100644 --- a/support/ab.c +++ b/support/ab.c @@ -258,6 +258,7 @@ struct data { /* --------------------- GLOBALS ---------------------------- */ int verbosity = 0; /* no verbosity by default */ +int recverrok = 0; /* ok to proceed after socket receive errors */ int posting = 0; /* GET by default */ int requests = 1; /* Number of requests to make */ int heartbeatres = 100; /* How often do we say we're alive */ @@ -317,7 +318,7 @@ BIO *bio_out,*bio_err; #endif /* store error cases */ -int err_length = 0, err_conn = 0, err_except = 0; +int err_length = 0, err_conn = 0, err_recv = 0, err_except = 0; int err_response = 0; apr_time_t start, endtime; @@ -760,8 +761,8 @@ static void output_results(int sig) printf("Complete requests: %ld\n", done); printf("Failed requests: %ld\n", bad); if (bad) - printf(" (Connect: %d, Length: %d, Exceptions: %d)\n", - err_conn, err_length, err_except); + printf(" (Connect: %d, Receive: %d, Length: %d, Exceptions: %d)\n", + err_conn, err_recv, err_length, err_except); printf("Write errors: %ld\n", epipe); if (err_response) printf("Non-2xx responses: %d\n", err_response); @@ -1329,10 +1330,18 @@ static void read_connection(struct connection * c) } /* catch legitimate fatal apr_socket_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_socket_recv", status); + err_recv++; + if (recverrok) { + bad++; + close_connection(c); + if (verbosity >= 1) { + char buf[120]; + fprintf(stderr,"%s: %s (%d)\n", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status); + } + return; + } else { + apr_err("apr_socket_recv", status); + } } } @@ -1819,6 +1828,7 @@ static void usage(const char *progname) fprintf(stderr, " -S Do not show confidence estimators and warnings.\n"); fprintf(stderr, " -g filename Output collected data to gnuplot format file.\n"); fprintf(stderr, " -e filename Output CSV file with percentages served\n"); + fprintf(stderr, " -r Don't exit on socket receive errors.\n"); fprintf(stderr, " -h Display usage information (this message)\n"); #ifdef USE_SSL fprintf(stderr, " -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)\n"); @@ -1981,7 +1991,7 @@ int main(int argc, const char * const argv[]) #endif apr_getopt_init(&opt, cntxt, argc, argv); - while ((status = apr_getopt(opt, "n:c:t:b:T:p:v:kVhwix:y:z:C:H:P:A:g:X:de:Sq" + while ((status = apr_getopt(opt, "n:c:t:b:T:p:v:rkVhwix:y:z:C:H:P:A:g:X:de:Sq" #ifdef USE_SSL "Z:f:" #endif @@ -2032,6 +2042,9 @@ int main(int argc, const char * const argv[]) exit(r); } break; + case 'r': + recverrok = 1; + break; case 'v': verbosity = atoi(optarg); break;