winemenubuilder: Create/release semaphore only around call to wineshelllink.
This commit is contained in:
parent
c03125a1be
commit
e340cafe74
|
@ -907,6 +907,7 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bAgain )
|
||||||
WCHAR szArgs[INFOTIPSIZE], szIconPath[MAX_PATH];
|
WCHAR szArgs[INFOTIPSIZE], szIconPath[MAX_PATH];
|
||||||
int iIconId = 0, r = -1;
|
int iIconId = 0, r = -1;
|
||||||
DWORD csidl = -1;
|
DWORD csidl = -1;
|
||||||
|
HANDLE hsem = NULL;
|
||||||
|
|
||||||
if ( !link )
|
if ( !link )
|
||||||
{
|
{
|
||||||
|
@ -1015,11 +1016,23 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bAgain )
|
||||||
escaped_args = escape(szArgs);
|
escaped_args = escape(szArgs);
|
||||||
escaped_description = escape(szDescription);
|
escaped_description = escape(szDescription);
|
||||||
|
|
||||||
|
/* running multiple instances of wineshelllink
|
||||||
|
at the same time may be dangerous */
|
||||||
|
hsem = CreateSemaphoreA( NULL, 1, 1, "winemenubuilder_semaphore");
|
||||||
|
if( WAIT_OBJECT_0 != WaitForSingleObject( hsem, INFINITE ) )
|
||||||
|
{
|
||||||
|
WINE_ERR("failed wait for semaphore\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
r = fork_and_wait("wineshelllink", link_name, escaped_path,
|
r = fork_and_wait("wineshelllink", link_name, escaped_path,
|
||||||
in_desktop_dir(csidl), escaped_args, icon_name,
|
in_desktop_dir(csidl), escaped_args, icon_name,
|
||||||
work_dir ? work_dir : "", escaped_description);
|
work_dir ? work_dir : "", escaped_description);
|
||||||
|
|
||||||
|
ReleaseSemaphore( hsem, 1, NULL );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (hsem) CloseHandle( hsem );
|
||||||
HeapFree( GetProcessHeap(), 0, icon_name );
|
HeapFree( GetProcessHeap(), 0, icon_name );
|
||||||
HeapFree( GetProcessHeap(), 0, work_dir );
|
HeapFree( GetProcessHeap(), 0, work_dir );
|
||||||
HeapFree( GetProcessHeap(), 0, link_name );
|
HeapFree( GetProcessHeap(), 0, link_name );
|
||||||
|
@ -1147,17 +1160,8 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
||||||
{
|
{
|
||||||
LPSTR token = NULL, p;
|
LPSTR token = NULL, p;
|
||||||
BOOL bAgain = FALSE;
|
BOOL bAgain = FALSE;
|
||||||
HANDLE hsem = CreateSemaphoreA( NULL, 1, 1, "winemenubuilder_semaphore");
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* running multiple instances of wineshelllink
|
|
||||||
at the same time may be dangerous */
|
|
||||||
if( WAIT_OBJECT_0 != WaitForSingleObject( hsem, INFINITE ) )
|
|
||||||
{
|
|
||||||
CloseHandle(hsem);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( p = cmdline; p && *p; )
|
for( p = cmdline; p && *p; )
|
||||||
{
|
{
|
||||||
token = next_token( &p );
|
token = next_token( &p );
|
||||||
|
@ -1182,8 +1186,5 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseSemaphore( hsem, 1, NULL );
|
|
||||||
CloseHandle( hsem );
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue