msi: Remove limit on number of handles.

This commit is contained in:
Dan Kegel 2006-08-28 07:51:30 -07:00 committed by Alexandre Julliard
parent 98ec9399c4
commit 29f0803c02
3 changed files with 30 additions and 13 deletions

View File

@ -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 *obj )
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 )
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, UINT type)
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;
}

View File

@ -271,7 +271,6 @@ typedef struct tagMSISUMMARYINFO
#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);

View File

@ -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);
}
if (!hviews[i])
break;
ok( (i == 0 || (hviews[i] != hviews[i-1])),