@@ -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));