diff mbox

[2/3] DAPL v2.0: ucm: cm object needs to be on work queue before req sent on wire

Message ID E3280858FA94444CA49D2BA02341C98301272F405B@orsmsx506.amr.corp.intel.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Arlin Davis Feb. 12, 2011, 7:33 p.m. UTC
None
diff mbox

Patch

diff --git a/dapl/openib_ucm/cm.c b/dapl/openib_ucm/cm.c
index 69f7610..b2db32c 100644
--- a/dapl/openib_ucm/cm.c
+++ b/dapl/openib_ucm/cm.c
@@ -951,7 +951,7 @@  dapli_cm_connect(DAPL_EP *ep, dp_ib_cm_handle_t cm)
 		 htons(cm->msg.dport));
 
 	dapl_os_lock(&cm->lock);
-	if (cm->state != DCM_REP_PENDING) {
+	if (cm->state != DCM_INIT && cm->state != DCM_REP_PENDING) {
 		dapl_os_unlock(&cm->lock);
 		return DAT_INVALID_STATE;
 	}
@@ -985,8 +985,9 @@  dapli_cm_connect(DAPL_EP *ep, dp_ib_cm_handle_t cm)
 				 DAT_INVALID_ADDRESS_UNREACHABLE);
 	}
 
+	cm->state = DCM_REP_PENDING;
 	cm->msg.op = htons(DCM_REQ);
-	dapl_os_get_time(&cm->timer); /* reply expected */
+	dapl_os_get_time(&cm->timer); /* reset reply timer */
 	if (ucm_send(&cm->hca->ib_trans, &cm->msg, 
 		     &cm->msg.p_data, ntohs(cm->msg.p_size))) {
 		dapl_os_unlock(&cm->lock);
@@ -994,10 +995,6 @@  dapli_cm_connect(DAPL_EP *ep, dp_ib_cm_handle_t cm)
 	}
 	dapl_os_unlock(&cm->lock);
 
-	/* first time through, link EP and CM, put on work queue */
-	if (!cm->retries) {
-		dapli_queue_conn(cm);
-	}
 	return DAT_SUCCESS;
 
 bail:
@@ -1658,7 +1655,10 @@  dapls_ib_connect(IN DAT_EP_HANDLE ep_handle,
 		dapl_os_memcpy(&cm->msg.p_data, p_data, p_size);
 	}
 	
-	cm->state = DCM_REP_PENDING;
+	cm->state = DCM_INIT;
+
+	/* link EP and CM, put on work queue */
+	dapli_queue_conn(cm);
 
 	/* build connect request, send to remote CM based on r_addr info */
 	return (dapli_cm_connect(ep, cm));