Implement thread safety for records.
This commit is contained in:
parent
5d7d188df5
commit
0f0b6c8c15
|
@ -41,6 +41,16 @@ static CRITICAL_SECTION_DEBUG MSI_handle_cs_debug =
|
|||
};
|
||||
static CRITICAL_SECTION MSI_handle_cs = { &MSI_handle_cs_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
static CRITICAL_SECTION MSI_object_cs;
|
||||
static CRITICAL_SECTION_DEBUG MSI_object_cs_debug =
|
||||
{
|
||||
0, 0, &MSI_object_cs,
|
||||
{ &MSI_object_cs_debug.ProcessLocksList,
|
||||
&MSI_object_cs_debug.ProcessLocksList },
|
||||
0, 0, { 0, (DWORD)(__FILE__ ": MSI_object_cs") }
|
||||
};
|
||||
static CRITICAL_SECTION MSI_object_cs = { &MSI_object_cs_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
MSIOBJECTHDR *msihandletable[MSIMAXHANDLES];
|
||||
|
||||
MSIHANDLE alloc_msihandle( MSIOBJECTHDR *obj )
|
||||
|
@ -143,6 +153,16 @@ void msiobj_addref( MSIOBJECTHDR *info )
|
|||
info->refcount++;
|
||||
}
|
||||
|
||||
void msiobj_lock( MSIOBJECTHDR *info )
|
||||
{
|
||||
EnterCriticalSection( &MSI_object_cs );
|
||||
}
|
||||
|
||||
void msiobj_unlock( MSIOBJECTHDR *info )
|
||||
{
|
||||
LeaveCriticalSection( &MSI_object_cs );
|
||||
}
|
||||
|
||||
int msiobj_release( MSIOBJECTHDR *info )
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -230,6 +230,8 @@ extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
|
|||
extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy );
|
||||
extern void msiobj_addref(MSIOBJECTHDR *);
|
||||
extern int msiobj_release(MSIOBJECTHDR *);
|
||||
extern void msiobj_lock(MSIOBJECTHDR *);
|
||||
extern void msiobj_unlock(MSIOBJECTHDR *);
|
||||
extern MSIHANDLE msiobj_findhandle( MSIOBJECTHDR *hdr );
|
||||
|
||||
/* add this table to the list of cached tables in the database */
|
||||
|
|
|
@ -116,7 +116,9 @@ unsigned int WINAPI MsiRecordGetFieldCount( MSIHANDLE handle )
|
|||
return 0;
|
||||
}
|
||||
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordGetFieldCount( rec );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
|
||||
return ret;
|
||||
|
@ -180,7 +182,9 @@ int WINAPI MsiRecordGetInteger( MSIHANDLE handle, unsigned int iField)
|
|||
if( !rec )
|
||||
return MSI_NULL_INTEGER;
|
||||
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordGetInteger( rec, iField );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
|
||||
return ret;
|
||||
|
@ -197,12 +201,14 @@ UINT WINAPI MsiRecordClearData( MSIHANDLE handle )
|
|||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
msiobj_lock( &rec->hdr );
|
||||
for( i=0; i<=rec->count; i++)
|
||||
{
|
||||
MSI_FreeField( &rec->fields[i] );
|
||||
rec->fields[i].type = MSIFIELD_NULL;
|
||||
rec->fields[i].u.iVal = 0;
|
||||
}
|
||||
msiobj_unlock( &rec->hdr );
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -232,7 +238,9 @@ UINT WINAPI MsiRecordSetInteger( MSIHANDLE handle, unsigned int iField, int iVal
|
|||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordSetInteger( rec, iField, iVal );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
@ -259,7 +267,9 @@ BOOL WINAPI MsiRecordIsNull( MSIHANDLE handle, unsigned int iField )
|
|||
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
||||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordIsNull( rec, iField );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
|
||||
|
@ -318,7 +328,9 @@ UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, unsigned int iField,
|
|||
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
||||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordGetStringA( rec, iField, szValue, pcchValue);
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
@ -385,7 +397,9 @@ UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, unsigned int iField,
|
|||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordGetStringW( rec, iField, szValue, pcchValue );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
@ -426,7 +440,9 @@ UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, unsigned int iField, LPCSTR s
|
|||
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
||||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordSetStringA( rec, iField, szValue );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
@ -463,7 +479,9 @@ UINT WINAPI MsiRecordSetStringW( MSIHANDLE handle, unsigned int iField, LPCWSTR
|
|||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordSetStringW( rec, iField, szValue );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
@ -554,7 +572,9 @@ UINT WINAPI MsiRecordReadStream(MSIHANDLE handle, unsigned int iField, char *buf
|
|||
rec = msihandle2msiinfo( handle, MSIHANDLETYPE_RECORD );
|
||||
if( !rec )
|
||||
return ERROR_INVALID_HANDLE;
|
||||
msiobj_lock( &rec->hdr );
|
||||
ret = MSI_RecordReadStream( rec, iField, buf, sz );
|
||||
msiobj_unlock( &rec->hdr );
|
||||
msiobj_release( &rec->hdr );
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue