]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
r6517: Generate a disconnect event for providers that do not generate
authorJames Lentini <jlentini@netapp.com>
Wed, 19 Apr 2006 16:30:37 +0000 (16:30 +0000)
committerJames Lentini <jlentini@netapp.com>
Wed, 19 Apr 2006 16:30:37 +0000 (16:30 +0000)
one automatically.
Signed-off-by: James Lentini <jlentini@netapp.com>
dapl/common/dapl_ep_util.c
dapl/common/dapl_ep_util.h
dapl/openib/dapl_ib_cm.c

index 8d9e7ccba91634c4a619573721e1b713ae448446..d11aed338ee82de647ebee0504467651704e73d1 100644 (file)
@@ -39,6 +39,7 @@
 #include "dapl_cookie.h"
 #include "dapl_adapter_util.h"
 #include "dapl_evd_util.h"
+#include "dapl_cr_util.h"               /* for callback routine */
 
 /*
  * Local definitions
@@ -569,6 +570,65 @@ bail:
 }
 #endif /* DAPL_DBG_IO_TRC */
 
+/*
+ * Generate a disconnect event on abruct close for older verbs providers 
+ * that do not do it automatically.
+ */
+
+void
+dapl_ep_legacy_post_disconnect(
+    DAPL_EP            *ep_ptr,
+    DAT_CLOSE_FLAGS    disconnect_flags)
+{
+    ib_cm_events_t     ib_cm_event;
+    DAPL_CR            *cr_ptr;
+
+    /*
+     * Acquire the lock and make sure we didn't get a callback
+     * that cleaned up.
+     */
+    dapl_os_lock ( &ep_ptr->header.lock );
+    if (disconnect_flags == DAT_CLOSE_ABRUPT_FLAG &&
+       ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING )
+    {
+       /*
+        * If this is an ABRUPT close, the provider will not generate
+        * a disconnect message so we do it manually here. Just invoke
+        * the CM callback as it will clean up the appropriate
+        * data structures, reset the state, and generate the event
+        * on the way out. Obtain the provider dependent cm_event to 
+        * pass into the callback for a disconnect.
+        */
+       ib_cm_event = dapls_ib_get_cm_event (DAT_CONNECTION_EVENT_DISCONNECTED);
+
+       cr_ptr = ep_ptr->cr_ptr;
+       dapl_os_unlock ( &ep_ptr->header.lock );
+
+       if (cr_ptr != NULL)
+       {
+           dapl_dbg_log (DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
+               "    dapl_ep_disconnect force callback on EP %p CM handle %x\n",
+                ep_ptr, cr_ptr->ib_cm_handle);
+
+           dapls_cr_callback (cr_ptr->ib_cm_handle,
+                              ib_cm_event,
+                              NULL,
+                              cr_ptr->sp_ptr);
+       }
+       else
+       {
+           dapl_evd_connection_callback (ep_ptr->cm_handle,
+                                         ib_cm_event,
+                                         NULL,
+                                         (void *) ep_ptr);
+       }
+    }
+    else
+    {
+       dapl_os_unlock ( &ep_ptr->header.lock );
+    }
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
index dfd93eac091247f715ded3628c4eaffd600e1997..579bb86c11f1ee666deb0bcdd3e63b45598cd3a5 100644 (file)
@@ -77,4 +77,9 @@ DAT_RETURN_SUBTYPE
 dapls_ep_state_subtype(
     IN  DAPL_EP                        *ep_ptr );
 
+extern void
+dapl_ep_legacy_post_disconnect(
+    DAPL_EP            *ep_ptr,
+    DAT_CLOSE_FLAGS    disconnect_flags);
+
 #endif /*  _DAPL_EP_UTIL_H_ */
index 1f72e3a79093229f7337ef2ec2649de0d32f5974..2ff2ba0c2d612142b06b8cc7ba263b0b3d5e6a58 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "dapl.h"
 #include "dapl_adapter_util.h"
+#include "dapl_ep_util.h"
 #include "dapl_evd_util.h"
 #include "dapl_cr_util.h"
 #include "dapl_name_service.h"
@@ -689,6 +690,8 @@ dapls_ib_disconnect (
                                     ep_ptr->cm_handle, status);
        }
 
+       dapl_ep_legacy_post_disconnect(ep_ptr, close_flags)
+
        return DAT_SUCCESS;
 }