From: Jeff Trawick Date: Fri, 12 Jan 2001 14:28:17 +0000 (+0000) Subject: open_postfile(): X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fec82d20209f961ec79375312d87002a189da8f8;p=apache open_postfile(): fix some return codes along the lines of OtherBill's comment fix some bad conditional logic for when to check if we read the wrong number of bytes git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87671 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/support/ab.c b/support/ab.c index 5267b1233f..0df71211fe 100644 --- a/support/ab.c +++ b/support/ab.c @@ -896,14 +896,14 @@ static void test(void) static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", AB_VERSION " <$Revision: 1.47 $> apache-2.0"); + printf("This is ApacheBench, Version %s\n", AB_VERSION " <$Revision: 1.48 $> 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.47 $"); + printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AB_VERSION, "$Revision: 1.48 $"); 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"); @@ -985,10 +985,14 @@ static int open_postfile(const char *pfile) apr_finfo_t finfo; apr_fileperms_t mode = APR_OS_DEFAULT; apr_size_t length; + apr_status_t rv; + char errmsg[120]; - if (apr_open(&postfd, pfile, APR_READ, mode, cntxt) != APR_SUCCESS) { - printf("Invalid postfile name (%s)\n", pfile); - return ENOENT; + rv = apr_open(&postfd, pfile, APR_READ, mode, cntxt); + if (rv != APR_SUCCESS) { + printf("Invalid postfile name (%s): %s\n", pfile, + apr_strerror(rv, errmsg, sizeof errmsg)); + return rv; } apr_getfileinfo(&finfo, postfd); @@ -996,13 +1000,19 @@ static int open_postfile(const char *pfile) postdata = (char *)malloc(postlen); if (!postdata) { printf("Can\'t alloc postfile buffer\n"); - return ENOMEM; + return APR_ENOMEM; } length = postlen; - if (apr_read(postfd, postdata, &length) != APR_SUCCESS && - length != postlen) { - printf("error reading postfilen"); - return EIO; + rv = apr_read(postfd, postdata, &length); + if (rv != APR_SUCCESS) { + printf("error reading postfile: %s\n", + apr_strerror(rv, errmsg, sizeof errmsg)); + return rv; + } + if (length != postlen) { + printf("error reading postfile: read only %d bytes", + length); + return APR_EINVAL; } return 0; }