MSI: MsiCloseAllHandles only closes handles allocated in the calling
thread
Mike McCormack
mike at codeweavers.com
Thu Jan 6 11:41:12 CST 2005
ChangeLog:
* MsiCloseAllHandles only closes handles allocated in the calling thread
-------------- next part --------------
Index: dlls/msi/handle.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/handle.c,v
retrieving revision 1.7
diff -u -r1.7 handle.c
--- dlls/msi/handle.c 27 Dec 2004 19:29:33 -0000 1.7
+++ dlls/msi/handle.c 6 Jan 2005 17:38:48 -0000
@@ -51,7 +51,13 @@
};
static CRITICAL_SECTION MSI_object_cs = { &MSI_object_cs_debug, -1, 0, 0, 0, 0 };
-MSIOBJECTHDR *msihandletable[MSIMAXHANDLES];
+typedef struct msi_handle_info_t
+{
+ MSIOBJECTHDR *obj;
+ DWORD dwThreadId;
+} msi_handle_info;
+
+static msi_handle_info msihandletable[MSIMAXHANDLES];
MSIHANDLE alloc_msihandle( MSIOBJECTHDR *obj )
{
@@ -62,13 +68,14 @@
/* find a slot */
for(i=0; i<MSIMAXHANDLES; i++)
- if( !msihandletable[i] )
+ if( !msihandletable[i].obj )
break;
- if( (i>=MSIMAXHANDLES) || msihandletable[i] )
+ if( (i>=MSIMAXHANDLES) || msihandletable[i].obj )
goto out;
msiobj_addref( obj );
- msihandletable[i] = obj;
+ msihandletable[i].obj = obj;
+ msihandletable[i].dwThreadId = GetCurrentThreadId();
ret = (MSIHANDLE) (i+1);
out:
TRACE("%p -> %ld\n", obj, ret );
@@ -87,13 +94,13 @@
goto out;
if( handle>=MSIMAXHANDLES )
goto out;
- if( !msihandletable[handle] )
+ if( !msihandletable[handle].obj )
goto out;
- if( msihandletable[handle]->magic != MSIHANDLE_MAGIC )
+ if( msihandletable[handle].obj->magic != MSIHANDLE_MAGIC )
goto out;
- if( type && (msihandletable[handle]->type != type) )
+ if( type && (msihandletable[handle].obj->type != type) )
goto out;
- ret = msihandletable[handle];
+ ret = msihandletable[handle].obj;
msiobj_addref( ret );
out:
@@ -111,7 +118,7 @@
EnterCriticalSection( &MSI_handle_cs );
for(i=0; (i<MSIMAXHANDLES) && !ret; i++)
- if( msihandletable[i] == hdr )
+ if( msihandletable[i].obj == hdr )
ret = i+1;
LeaveCriticalSection( &MSI_handle_cs );
@@ -190,6 +197,9 @@
return ret;
}
+/***********************************************************
+ * MsiCloseHandle [MSI.@]
+ */
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
{
MSIOBJECTHDR *info;
@@ -210,7 +220,7 @@
}
msiobj_release( info );
- msihandletable[handle-1] = NULL;
+ msihandletable[handle-1].obj = NULL;
ret = ERROR_SUCCESS;
TRACE("handle %lx Destroyed\n", handle);
@@ -222,14 +232,28 @@
return ret;
}
+/***********************************************************
+ * MsiCloseAllHandles [MSI.@]
+ *
+ * Closes all handles owned by the current thread
+ *
+ * RETURNS:
+ * The number of handles closed
+ */
UINT WINAPI MsiCloseAllHandles(void)
{
- UINT i;
+ UINT i, n=0;
TRACE("\n");
for(i=0; i<MSIMAXHANDLES; i++)
- MsiCloseHandle( i+1 );
+ {
+ if(msihandletable[i].dwThreadId == GetCurrentThreadId())
+ {
+ MsiCloseHandle( i+1 );
+ n++;
+ }
+ }
- return 0;
+ return n;
}
More information about the wine-patches
mailing list