Dan Kegel : msi: Remove limit on number of handles.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 28 12:35:32 CDT 2006


Module: wine
Branch: master
Commit: 29f0803c0239fe2495ffddd96471cd03475dc0db
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=29f0803c0239fe2495ffddd96471cd03475dc0db

Author: Dan Kegel <dank at kegel.com>
Date:   Mon Aug 28 07:51:30 2006 -0700

msi: Remove limit on number of handles.

---

 dlls/msi/handle.c   |   35 +++++++++++++++++++++++++++++------
 dlls/msi/msipriv.h  |    1 -
 dlls/msi/tests/db.c |    7 +------
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/dlls/msi/handle.c b/dlls/msi/handle.c
index 1cd82b3..3bcdb46 100644
--- a/dlls/msi/handle.c
+++ b/dlls/msi/handle.c
@@ -57,7 +57,8 @@ typedef struct msi_handle_info_t
     DWORD dwThreadId;
 } msi_handle_info;
 
-static msi_handle_info msihandletable[MSIMAXHANDLES];
+static msi_handle_info *msihandletable = NULL;
+static int msihandletable_size = 0;
 
 MSIHANDLE alloc_msihandle( MSIOBJECTHDR *obj )
 {
@@ -67,11 +68,29 @@ MSIHANDLE alloc_msihandle( MSIOBJECTHDR 
     EnterCriticalSection( &MSI_handle_cs );
 
     /* find a slot */
-    for(i=0; i<MSIMAXHANDLES; i++)
+    for(i=0; i<msihandletable_size; i++)
         if( !msihandletable[i].obj )
             break;
-    if( (i>=MSIMAXHANDLES) || msihandletable[i].obj )
-        goto out;
+    if( i==msihandletable_size )
+    {
+        msi_handle_info *p;
+        int newsize;
+        if (msihandletable_size == 0)
+        {
+            newsize = 256;
+            p = msi_alloc_zero(newsize*sizeof(msi_handle_info));
+        }
+        else 
+	{
+            newsize = msihandletable_size * 2;
+            p = msi_realloc_zero(msihandletable,
+                            newsize*sizeof(msi_handle_info));
+	}
+        if (!p)
+            goto out;
+        msihandletable = p;
+        msihandletable_size = newsize;
+    }
 
     msiobj_addref( obj );
     msihandletable[i].obj = obj;
@@ -92,7 +111,7 @@ void *msihandle2msiinfo(MSIHANDLE handle
     handle--;
     if( handle<0 )
         goto out;
-    if( handle>=MSIMAXHANDLES )
+    if( handle>=msihandletable_size )
         goto out;
     if( !msihandletable[handle].obj )
         goto out;
@@ -230,14 +249,18 @@ UINT WINAPI MsiCloseAllHandles(void)
 
     TRACE("\n");
 
-    for(i=0; i<MSIMAXHANDLES; i++)
+    EnterCriticalSection( &MSI_handle_cs );
+    for(i=0; i<msihandletable_size; i++)
     {
         if(msihandletable[i].dwThreadId == GetCurrentThreadId())
         {
+            LeaveCriticalSection( &MSI_handle_cs );
             MsiCloseHandle( i+1 );
+            EnterCriticalSection( &MSI_handle_cs );
             n++;
         }
     }
+    LeaveCriticalSection( &MSI_handle_cs );
 
     return n;
 }
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index abaa347..6f771da 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -271,7 +271,6 @@ #define MSI_BUILDNUMBER 4000
 #define GUID_SIZE 39
 
 #define MSIHANDLE_MAGIC 0x4d434923
-#define MSIMAXHANDLES 0xf0
 
 DEFINE_GUID(CLSID_IMsiServer,   0x000C101C,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
 DEFINE_GUID(CLSID_IMsiServerX1, 0x000C103E,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c
index 0a5b230..6b5336d 100644
--- a/dlls/msi/tests/db.c
+++ b/dlls/msi/tests/db.c
@@ -1376,12 +1376,7 @@ static void test_handle_limit(void)
         r = MsiDatabaseOpenView(hdb, szQueryBuf, &hviews[i]);
         ok( r == ERROR_SUCCESS, "failed to open query %d\n", i);
         ok( hviews[i] != 0xdeadbeeb, "no handle set\n");
-        if (i < 0xef)
-            ok( hviews[i] != 0, "%d'th handle is NULL\n", i);
-        else
-            todo_wine {
-                ok( hviews[i] != 0, "%d'th handle is NULL\n", i);
-            }
+        ok( hviews[i] != 0, "%d'th handle is NULL\n", i);
         if (!hviews[i])
             break;
         ok( (i == 0 || (hviews[i] != hviews[i-1])),




More information about the wine-cvs mailing list