From b6faa376756de16c188a311e2dcd9593889f87d0 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Mon, 31 Jul 2000 14:50:50 +0000 Subject: [PATCH] Don't use perror() to report the failure of an APR function. Introduce apr_err() for that purpose. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85962 13f79535-47bb-0310-9956-ffa450edef68 --- support/ab.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/support/ab.c b/support/ab.c index eef386a03d..65b5c86696 100644 --- a/support/ab.c +++ b/support/ab.c @@ -230,17 +230,24 @@ ap_xlate_t *from_ascii, *to_ascii; /* --------------------------------------------------------- */ -/* simple little function to perror and exit */ +/* simple little function to write an error string and exit */ static void err(char *s) { - if (errno) { - perror(s); - } - else { - printf("%s", s); - } - exit(errno); + fprintf(stderr, "%s", s); + exit(1); +} + +/* simple little function to write an APR error string and exit */ + +static void apr_err(char *s, ap_status_t rv) +{ + char buf[120]; + + fprintf(stderr, + "%s: %s (%d)\n", + s, ap_strerror(rv, buf, sizeof buf), rv); + exit(rv); } /* --------------------------------------------------------- */ @@ -483,11 +490,11 @@ static void start_connect(struct connection *c) c->cbx = 0; c->gotheader = 0; - if (ap_create_tcp_socket(&c->aprsock, cntxt) != APR_SUCCESS) { - err("Socket:"); + if ((rv = ap_create_tcp_socket(&c->aprsock, cntxt)) != APR_SUCCESS) { + apr_err("Socket:", rv); } - if (ap_set_remote_port(c->aprsock, port) != APR_SUCCESS) { - err("Port:"); + if ((rv = ap_set_remote_port(c->aprsock, port)) != APR_SUCCESS) { + apr_err("Port:", rv); } c->start = ap_now(); if ((rv = ap_connect(c->aprsock, hostname)) != APR_SUCCESS) { @@ -501,7 +508,9 @@ static void start_connect(struct connection *c) ap_close_socket(c->aprsock); err_conn++; if (bad++ > 10) { - err("\nTest aborted after 10 failures\n\n"); + fprintf(stderr, + "\nTest aborted after 10 failures\n\n"); + apr_err("ap_connect()", rv); } start_connect(c); return; @@ -725,8 +734,8 @@ static void test(void) ap_interval_time_t timeout; ap_int16_t rv; int i; -#ifdef NOT_ASCII ap_status_t status; +#ifdef NOT_ASCII ap_size_t inbytes_left, outbytes_left; #endif @@ -814,13 +823,13 @@ static void test(void) timeout = 30 * AP_USEC_PER_SEC; n = concurrency; - ap_poll(readbits, &n, timeout); + status = ap_poll(readbits, &n, timeout); + if (status != APR_SUCCESS) + apr_err("ap_poll", status); if (!n) { err("\nServer timed out\n\n"); } - if (n < 1) - err("ap_poll"); for (i = 0; i < concurrency; i++) { ap_get_revents(&rv, con[i].aprsock, readbits); @@ -853,14 +862,14 @@ static void test(void) static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", AB_VERSION " <$Revision: 1.19 $> apache-2.0"); + printf("This is ApacheBench, Version %s\n", AB_VERSION " <$Revision: 1.20 $> apache-2.0"); printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); printf("Copyright (c) 1998-2000 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", AB_VERSION, "$Revision: 1.19 $"); + printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AB_VERSION, "$Revision: 1.20 $"); printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
\n"); printf(" Copyright (c) 1998-2000 The Apache Software Foundation, http://www.apache.org/
\n"); printf("

\n

\n"); -- 2.40.0