]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
scm: cleanup orphaned UD CR's when destroying the EP
authorArlin Davis <arlin.r.davis@intel.com>
Wed, 10 Jun 2009 16:09:56 +0000 (09:09 -0700)
committerArlin Davis <arlin.r.davis@intel.com>
Wed, 10 Jun 2009 17:08:54 +0000 (10:08 -0700)
UD CR objects are kept active because of direct private data references
from CONN events. The cr->socket is closed and marked inactive but the
object remains allocated and queued on the CR resource list. There can
be multiple CR's associated with a given EP and there is no way to
determine when consumer is finished with event until the dat_ep_free.
Schedule destruction for all CR's associated with this EP during
free call. cr_thread will complete cleanup with state of SCM_DESTROY.

Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
dapl/openib_scm/dapl_ib_qp.c

index e14d4d9a26f264a1b85cdc3f73a294f0124555bf..f30da11e7a4bd704f3e724dc926ff241f29c7741 100644 (file)
@@ -189,6 +189,44 @@ DAT_RETURN dapls_ib_qp_free(IN DAPL_IA * ia_ptr, IN DAPL_EP * ep_ptr)
                ep_ptr->qp_handle = IB_INVALID_HANDLE;
        }
 
+#ifdef DAT_EXTENSIONS
+{
+       dp_ib_cm_handle_t cr, next_cr;
+
+       /* 
+        * UD CR objects are kept active because of direct private data references
+        * from CONN events. The cr->socket is closed and marked inactive but the 
+        * object remains allocated and queued on the CR resource list. There can
+        * be multiple CR's associated with a given EP. There is no way to determine 
+        * when consumer is finished with event until the dat_ep_free.
+        *
+        * Schedule destruction for all CR's associated with this EP, cr_thread will
+        * complete the cleanup with state == SCM_DESTROY. 
+        */ 
+       dapl_os_lock(&ia_ptr->hca_ptr->ib_trans.lock);
+       if (!dapl_llist_is_empty((DAPL_LLIST_HEAD*)
+                                 &ia_ptr->hca_ptr->ib_trans.list))
+            next_cr = dapl_llist_peek_head((DAPL_LLIST_HEAD*)
+                                           &ia_ptr->hca_ptr->ib_trans.list);
+       else
+           next_cr = NULL;
+
+       while (next_cr) {
+               cr = next_cr;
+               next_cr = dapl_llist_next_entry((DAPL_LLIST_HEAD*)
+                                               &ia_ptr->hca_ptr->ib_trans.list,
+                                               (DAPL_LLIST_ENTRY*)&cr->entry);
+               if (cr->ep == ep_ptr)  {
+                       dapl_dbg_log(DAPL_DBG_TYPE_EP,
+                                    " qp_free CR: ep %p cr %p\n", ep_ptr, cr);
+                       cr->state = SCM_DESTROY;
+               }
+       }
+       dapl_os_unlock(&ia_ptr->hca_ptr->ib_trans.lock);
+       send(ia_ptr->hca_ptr->ib_trans.scm[1], "w", sizeof "w", 0);
+}
+#endif
+
        return DAT_SUCCESS;
 }