MSI: fix refcounting, use Interlocked functions

Mike McCormack mike at codeweavers.com
Thu Jan 20 06:54:17 CST 2005


ChangeLog:
* fix refcounting, use Interlocked functions
-------------- next part --------------
Index: dlls/msi/handle.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/handle.c,v
retrieving revision 1.8
diff -u -p -r1.8 handle.c
--- dlls/msi/handle.c	6 Jan 2005 20:43:04 -0000	1.8
+++ dlls/msi/handle.c	20 Jan 2005 12:53:59 -0000
@@ -157,7 +157,7 @@ void msiobj_addref( MSIOBJECTHDR *info )
         return;
     }
 
-    info->refcount++;
+    InterlockedIncrement(&info->refcount);
 }
 
 void msiobj_lock( MSIOBJECTHDR *info )
@@ -185,12 +185,12 @@ int msiobj_release( MSIOBJECTHDR *info )
         return -1;
     }
 
-    ret = info->refcount--;
-    if (info->refcount == 0)
+    ret = InterlockedDecrement( &info->refcount );
+    if( ret==0 )
     {
-    if( info->destructor )
+        if( info->destructor )
             info->destructor( info );
-    HeapFree( GetProcessHeap(), 0, info );
+        HeapFree( GetProcessHeap(), 0, info );
         TRACE("object %p destroyed\n", info);
     }
 
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.49
diff -u -p -r1.49 msi.c
--- dlls/msi/msi.c	19 Jan 2005 16:58:03 -0000	1.49
+++ dlls/msi/msi.c	20 Jan 2005 12:53:59 -0000
@@ -228,9 +228,12 @@ BOOL encode_base85_guid( GUID *guid, LPW
 VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
 {
     MSIDATABASE *db = (MSIDATABASE *) arg;
+    DWORD r;
 
     free_cached_tables( db );
-    IStorage_Release( db->storage );
+    r = IStorage_Release( db->storage );
+    if( r )
+        ERR("database reference count was not zero (%ld)\n", r);
 }
 
 UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
Index: dlls/msi/msipriv.h
===================================================================
RCS file: /home/wine/wine/dlls/msi/msipriv.h,v
retrieving revision 1.35
diff -u -p -r1.35 msipriv.h
--- dlls/msi/msipriv.h	19 Jan 2005 19:07:40 -0000	1.35
+++ dlls/msi/msipriv.h	20 Jan 2005 12:54:00 -0000
@@ -53,7 +53,7 @@ struct tagMSIOBJECTHDR
 {
     UINT magic;
     UINT type;
-    UINT refcount;
+    DWORD refcount;
     msihandledestructor destructor;
     struct tagMSIOBJECTHDR *next;
     struct tagMSIOBJECTHDR *prev;
Index: dlls/msi/msiquery.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msiquery.c,v
retrieving revision 1.17
diff -u -p -r1.17 msiquery.c
--- dlls/msi/msiquery.c	10 Dec 2004 15:24:52 -0000	1.17
+++ dlls/msi/msiquery.c	20 Jan 2005 12:54:00 -0000
@@ -461,6 +461,8 @@ UINT WINAPI MsiDatabaseCommit( MSIHANDLE
 
     /* FIXME: unlock the database */
 
+    msiobj_release( &db->hdr );
+
     return r;
 }
 


More information about the wine-patches mailing list