]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
[5/5,librdmacm] rping: added checks to the return values functions
authorDotan Barak <dotanb@dev.mellanox.co.il>
Tue, 9 Oct 2012 12:27:52 +0000 (12:27 +0000)
committerSean Hefty <sean.hefty@intel.com>
Tue, 9 Oct 2012 17:00:26 +0000 (10:00 -0700)
This will make rping to exit with return value other than zero in case of an
error.

Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
examples/rping.c

index 32bd70ac4d6a8029f8c160a9f2af2cb5c41dfba8..1c4688c55f5bbb08814a66a07139e6a3fae48d71 100644 (file)
@@ -881,7 +881,14 @@ static int rping_run_server(struct rping_cb *cb)
                goto err2;
        }
 
-       rping_test_server(cb);
+       ret = rping_test_server(cb);
+       if (ret) {
+               fprintf(stderr, "rping server failed: %d\n", ret);
+               goto err3;
+       }
+
+       ret = 0;
+err3:
        rdma_disconnect(cb->child_cm_id);
        pthread_join(cb->cqthread, NULL);
        rdma_destroy_id(cb->child_cm_id);
@@ -1049,7 +1056,14 @@ static int rping_run_client(struct rping_cb *cb)
                goto err2;
        }
 
-       rping_test_client(cb);
+       ret = rping_test_client(cb);
+       if (ret) {
+               fprintf(stderr, "rping client failed: %d\n", ret);
+               goto err3;
+       }
+
+       ret = 0;
+err3:
        rdma_disconnect(cb->cm_id);
        pthread_join(cb->cqthread, NULL);
 err2:
@@ -1189,6 +1203,7 @@ int main(int argc, char *argv[])
        cb->cm_channel = rdma_create_event_channel();
        if (!cb->cm_channel) {
                perror("rdma_create_event_channel");
+               ret = ENOMEM;
                goto out;
        }
 
@@ -1206,8 +1221,9 @@ int main(int argc, char *argv[])
                        ret = rping_run_persistent_server(cb);
                else
                        ret = rping_run_server(cb);
-       } else
+       } else {
                ret = rping_run_client(cb);
+       }
 
        DEBUG_LOG("destroy cm_id %p\n", cb->cm_id);
        rdma_destroy_id(cb->cm_id);