From f959bb786cd884bf4d2a5da4d299da6297d65293 Mon Sep 17 00:00:00 2001 From: James Lentini Date: Wed, 19 Apr 2006 16:30:37 +0000 Subject: [PATCH] r6517: Generate a disconnect event for providers that do not generate one automatically. Signed-off-by: James Lentini --- dapl/common/dapl_ep_util.c | 60 ++++++++++++++++++++++++++++++++++++++ dapl/common/dapl_ep_util.h | 5 ++++ dapl/openib/dapl_ib_cm.c | 3 ++ 3 files changed, 68 insertions(+) diff --git a/dapl/common/dapl_ep_util.c b/dapl/common/dapl_ep_util.c index 8d9e7cc..d11aed3 100644 --- a/dapl/common/dapl_ep_util.c +++ b/dapl/common/dapl_ep_util.c @@ -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 diff --git a/dapl/common/dapl_ep_util.h b/dapl/common/dapl_ep_util.h index dfd93ea..579bb86 100644 --- a/dapl/common/dapl_ep_util.h +++ b/dapl/common/dapl_ep_util.h @@ -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_ */ diff --git a/dapl/openib/dapl_ib_cm.c b/dapl/openib/dapl_ib_cm.c index 1f72e3a..2ff2ba0 100644 --- a/dapl/openib/dapl_ib_cm.c +++ b/dapl/openib/dapl_ib_cm.c @@ -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; } -- 2.41.0