]> granicus.if.org Git - apache/commitdiff
open_postfile():
authorJeff Trawick <trawick@apache.org>
Fri, 12 Jan 2001 14:28:17 +0000 (14:28 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 12 Jan 2001 14:28:17 +0000 (14:28 +0000)
  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

support/ab.c

index 5267b1233fb43f267f0ebffbfe45efc3aa9316b7..0df71211fec3c91d1ef229a841e99d489c994e98 100644 (file)
@@ -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("<p>\n");
-        printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AB_VERSION, "$Revision: 1.47 $");
+        printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AB_VERSION, "$Revision: 1.48 $");
         printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
         printf(" Copyright (c) 1998-2000 The Apache Software Foundation, http://www.apache.org/<br>\n");
         printf("</p>\n<p>\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;
 }