apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1462766 - in /apr/apr/branches/1.5.x: ./ test/sockperf.c
Date Sat, 30 Mar 2013 14:22:36 GMT
Author: trawick
Date: Sat Mar 30 14:22:35 2013
New Revision: 1462766

URL: http://svn.apache.org/r1462766
Log:
merge r1460399 from trunk

clean up a bit of error handling just to get rid of

  sockperf.c: In function 'main':
  sockperf.c:206:18: warning: variable 'rv' set but not used [-Wunused-but-set-variable]

Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/test/sockperf.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1460399

Modified: apr/apr/branches/1.5.x/test/sockperf.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/test/sockperf.c?rev=1462766&r1=1462765&r2=1462766&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/test/sockperf.c (original)
+++ apr/apr/branches/1.5.x/test/sockperf.c Sat Mar 30 14:22:35 2013
@@ -96,8 +96,10 @@ static apr_status_t sendRecvBuffer(apr_t
 
         rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, APR_PROTO_TCP,
                            pool);
-        if (rv != APR_SUCCESS)
+        if (rv != APR_SUCCESS) {
+            reportError("Unable to create IPv4 stream socket", rv, pool);
             return rv;
+        }
 
         rv = apr_socket_connect(sock, sockAddr);
         if (rv != APR_SUCCESS) {
@@ -110,16 +112,21 @@ static apr_status_t sendRecvBuffer(apr_t
     }
 
     recvBuf = apr_palloc(pool, size);
-    if (! recvBuf)
+    if (! recvBuf) {
+        reportError("Unable to allocate buffer", ENOMEM, pool);
         return ENOMEM;
+    }
+
     *t = 0;
 
     /* START! */
     testStart = apr_time_now();
     rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, APR_PROTO_TCP,
                            pool);
-    if (rv != APR_SUCCESS)
+    if (rv != APR_SUCCESS) {
+        reportError("Unable to create IPv4 stream socket", rv, pool);
         return rv;
+    }
 
     rv = apr_socket_connect(sock, sockAddr);
     if (rv != APR_SUCCESS) {
@@ -146,8 +153,10 @@ static apr_status_t sendRecvBuffer(apr_t
         do {
             len = thistime;
             rv = apr_socket_recv(sock, &recvBuf[size - thistime], &len);
-            if (rv != APR_SUCCESS)
+            if (rv != APR_SUCCESS) {
+                reportError("Error receiving from socket", rv, pool);
                 break;
+            }
             thistime -= len;
         } while (thistime);
     }
@@ -218,14 +227,18 @@ int main(int argc, char **argv)
     results = (struct testResult *)apr_pcalloc(pool, 
                                         sizeof(*results) * nTests);
 
-    for(i = 0; i < nTests; i++) {
+    for (i = 0; i < nTests; i++) {
         printf("Test -> %c\n", testRuns[i].c);
         results[i].size = testRuns[i].size * (apr_size_t)TEST_SIZE;
         rv = runTest(&testRuns[i], &results[i], pool);
+        if (rv != APR_SUCCESS) {
+            /* error already reported */
+            exit(1);
+        }
     }
 
     printf("Tests Complete!\n");
-    for(i = 0; i < nTests; i++) {
+    for (i = 0; i < nTests; i++) {
         int j;
         apr_time_t totTime = 0;
         printf("%10d byte block:\n", results[i].size);



Mime
View raw message