Proper finalization in StartServiceW
Alexander Yaworsky
yaworsky at migusoft.ru
Sun Sep 12 23:13:42 CDT 2004
Hello
ChangeLog:
Proper finalization in StartServiceW
Index: dlls/advapi32/service.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/service.c,v
retrieving revision 1.54
diff -u -r1.54 service.c
--- dlls/advapi32/service.c 10 Sep 2004 21:12:25 -0000 1.54
+++ dlls/advapi32/service.c 13 Sep 2004 03:17:17 -0000
@@ -871,11 +871,13 @@
struct sc_handle *hsvc = hService;
WCHAR path[MAX_PATH],str[MAX_PATH];
- DWORD type,size;
+ DWORD type,size,last_error;
long r;
HANDLE data,wait;
PROCESS_INFORMATION procinfo;
STARTUPINFOW startupinfo;
+ BOOL ret = FALSE;
+
TRACE("(%p,%ld,%p)\n",hService,dwNumServiceArgs,
lpServiceArgVectors);
@@ -934,19 +936,31 @@
if(r == FALSE)
{
ERR("Couldn't start process\n");
- /* ReleaseSemaphore(data, 1, NULL);
- return FALSE; */
+ last_error = GetLastError();
+ goto done;
}
+ CloseHandle( procinfo.hThread );
/* docs for StartServiceCtrlDispatcher say this should be 30 sec */
r = WaitForSingleObject(wait,30000);
+ if( WAIT_FAILED == r )
+ {
+ last_error = GetLastError();
+ CloseHandle( procinfo.hProcess );
+ goto done;
+ }
- ReleaseSemaphore(data, 1, NULL);
-
- if( r == WAIT_FAILED)
- return FALSE;
+ /* allright */
+ CloseHandle( procinfo.hProcess );
+ last_error = 0;
+ ret = TRUE;
- return TRUE;
+done:
+ CloseHandle( wait );
+ ReleaseSemaphore(data, 1, NULL);
+ CloseHandle( data );
+ SetLastError( last_error );
+ return ret;
}
/******************************************************************************
More information about the wine-patches
mailing list