From: Sean Hefty Date: Mon, 18 Nov 2013 21:12:04 +0000 (-0800) Subject: rping: Fix server reporting error on exit X-Git-Tag: v1.0.18~5 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=b70a390d8bd8a679571f06ab82e42d68a99bc7d2;p=~shefty%2Flibrdmacm.git rping: Fix server reporting error on exit Commit e57196c71ddd850e14f3e66355f02786e4914f72 rping: added checks to the return values functions resulted in the rping server always reporting that it failed. Fix this by only failing in the case of an unexpected termination, and not the result of the client completing. Signed-off-by: Sean Hefty --- diff --git a/examples/rping.c b/examples/rping.c index 1c4688c5..949cbe67 100644 --- a/examples/rping.c +++ b/examples/rping.c @@ -82,6 +82,7 @@ enum test_state { RDMA_READ_COMPLETE, RDMA_WRITE_ADV, RDMA_WRITE_COMPLETE, + DISCONNECTED, ERROR }; @@ -217,6 +218,7 @@ static int rping_cma_event_handler(struct rdma_cm_id *cma_id, case RDMA_CM_EVENT_DISCONNECTED: fprintf(stderr, "%s DISCONNECT EVENT...\n", cb->server ? "server" : "client"); + cb->state = DISCONNECTED; sem_post(&cb->sem); break; @@ -718,7 +720,7 @@ static int rping_test_server(struct rping_cb *cb) DEBUG_LOG("server posted go ahead\n"); } - return ret; + return (cb->state == DISCONNECTED) ? 0 : ret; } static int rping_bind_server(struct rping_cb *cb) @@ -966,7 +968,7 @@ static int rping_test_client(struct rping_cb *cb) printf("ping data: %s\n", cb->rdma_buf); } - return ret; + return (cb->state == DISCONNECTED) ? 0 : ret; } static int rping_connect_client(struct rping_cb *cb) @@ -1203,7 +1205,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; + ret = errno; goto out; }