[openib-general] [PATCH] librdmacm/examples/rping.c
Boyd R. Faulkner
faulkner at opengridcomputing.com
Tue Jun 13 09:24:07 PDT 2006
This patch resolves a race condition between the receipt of
a connection established event and a receive completion from
the client. The server no longer goes to connected state but
merely waits for the READ_ADV state to begin its looping. This
keeps the server from going back to CONNECTED from the later
states if the connection established event comes in after the
receive completion (i.e. the loop starts).
Signed-off-by: Boyd Faulkner <faulkner at opengridcomputing.com>
Index: rping.c
===================================================================
--- rping.c (revision 7960)
+++ rping.c (working copy)
@@ -182,7 +182,13 @@
case RDMA_CM_EVENT_ESTABLISHED:
DEBUG_LOG("ESTABLISHED\n");
- cb->state = CONNECTED;
+
+ /*
+ * Server will wake up when first RECV completes.
+ */
+ if (!cb->server) {
+ cb->state = CONNECTED;
+ }
sem_post(&cb->sem);
break;
@@ -197,7 +203,7 @@
break;
case RDMA_CM_EVENT_DISCONNECTED:
- fprintf(stderr, "DISCONNECT EVENT...\n");
+ fprintf(stderr, "%s DISCONNECT EVENT...\n", cb->server ? "server" : "client");
sem_post(&cb->sem);
break;
@@ -225,7 +231,7 @@
DEBUG_LOG("Received rkey %x addr %" PRIx64 "len %d from peer\n",
cb->remote_rkey, cb->remote_addr, cb->remote_len);
- if (cb->state == CONNECTED || cb->state == RDMA_WRITE_COMPLETE)
+ if (cb->state <= CONNECTED || cb->state == RDMA_WRITE_COMPLETE)
cb->state = RDMA_READ_ADV;
else
cb->state = RDMA_WRITE_ADV;
--
Boyd R. Faulkner
Open Grid Computing, Inc.
Phone: 512-343-9196 x109
Fax: 512-343-5450
More information about the general
mailing list