[ofw] [PATCH] Fix object destruction

Fab Tillier ftillier at windows.microsoft.com
Wed Jul 2 10:24:06 PDT 2008


This patch fixes IBAL object destruction.  It does the following:

1. Removes forcing synchronous destruction for user-mode exported objects.  This isn't needed, and slows down cleanup of the object hierarchy.

2. Clears the user-mode exported handle from the handle table before invoking the 'destroying' callback of an object, so that all further reference on the object will fail.  Currently, an IOCTL could take a reference on an object after the 'destroying' callback has returned.

Signed-off-by: Fab Tillier <ftillier at microsoft.com>

diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\core\al\al_common.c trunk\core\al\al_common.c
--- old\core\al\al_common.c     Thu Jun 26 20:35:14 2008
+++ trunk\core\al\al_common.c   Wed Jul 02 10:19:12 2008
@@ -187,7 +187,7 @@ init_al_obj(

        p_obj->context = context;

-       if( async_destroy && !(p_obj->type & AL_OBJ_SUBTYPE_UM_EXPORT) )
+       if( async_destroy )
                p_obj->pfn_destroy = async_destroy_obj;
        else
                p_obj->pfn_destroy = sync_destroy_obj;
@@ -586,18 +586,21 @@ destroy_obj(
        cl_spinlock_release( &p_obj->lock );
        deref_al_obj( p_obj );

-       /* Notify the object that it is being destroyed. */
-       if( p_obj->pfn_destroying )
-               p_obj->pfn_destroying( p_obj );
-
 #ifdef CL_KERNEL
-       /* Release this object's handle. */
+       /*
+        * Release this object's handle.  We must do this before calling the
+        * destroy callback so that any IOCTLs referencing this object will fail
+        */
        if( p_obj->hdl != AL_INVALID_HANDLE )
        {
                CL_ASSERT( p_obj->h_al );
                al_hdl_free_obj( p_obj );
        }
 #endif
+
+       /* Notify the object that it is being destroyed. */
+       if( p_obj->pfn_destroying )
+               p_obj->pfn_destroying( p_obj );

        if( p_obj->p_parent_obj )
                detach_al_obj( p_obj );
-------------- next part --------------
A non-text attachment was scrubbed...
Name: al_obj_destroy.patch
Type: application/octet-stream
Size: 1218 bytes
Desc: al_obj_destroy.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080702/a227124a/attachment.obj>


More information about the ofw mailing list