]> granicus.if.org Git - apache/commitdiff
ab: Add -r option to continue after socket receive errors.
authorJeff Trawick <trawick@apache.org>
Thu, 8 Mar 2007 21:00:07 +0000 (21:00 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 8 Mar 2007 21:00:07 +0000 (21:00 +0000)
Submitted by: Filip Hanik <devlist hanik.com>
Reviewed by: trawick

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@516175 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/ab.c

diff --git a/CHANGES b/CHANGES
index 46e3f5083a5a64b2ed1a983e47ecf7ff7d4f767d..bd4bd1cb6fef641856793604b170007ded9cdc6c 100644 (file)
--- 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 <devlist hanik.com>]
+
   *) 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 <oscaremma gmail.com>]
index 14ee7ff64993705d2dcb5cc1b9b86863031e5f81..37bcb8a4a7a42222f3ef072693968ff72c0827a1 100644 (file)
@@ -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;