Misha Koshelev : winemenubuilder: Create/
release semaphore only around call to wineshelllink.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jun 28 08:08:07 CDT 2007
Module: wine
Branch: master
Commit: e340cafe741ee7d686ce63e145313b44677e1852
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e340cafe741ee7d686ce63e145313b44677e1852
Author: Misha Koshelev <mk144210 at bcm.edu>
Date: Wed Jun 27 20:23:30 2007 -0500
winemenubuilder: Create/release semaphore only around call to wineshelllink.
---
programs/winemenubuilder/winemenubuilder.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 7c537ca..cac3abf 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -907,6 +907,7 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bAgain )
WCHAR szArgs[INFOTIPSIZE], szIconPath[MAX_PATH];
int iIconId = 0, r = -1;
DWORD csidl = -1;
+ HANDLE hsem = NULL;
if ( !link )
{
@@ -1015,11 +1016,23 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bAgain )
escaped_args = escape(szArgs);
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,
in_desktop_dir(csidl), escaped_args, icon_name,
work_dir ? work_dir : "", escaped_description);
+ ReleaseSemaphore( hsem, 1, NULL );
+
cleanup:
+ if (hsem) CloseHandle( hsem );
HeapFree( GetProcessHeap(), 0, icon_name );
HeapFree( GetProcessHeap(), 0, work_dir );
HeapFree( GetProcessHeap(), 0, link_name );
@@ -1147,17 +1160,8 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
{
LPSTR token = NULL, p;
BOOL bAgain = FALSE;
- HANDLE hsem = CreateSemaphoreA( NULL, 1, 1, "winemenubuilder_semaphore");
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; )
{
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;
}
More information about the wine-cvs
mailing list