Revised: Proper finalization in StartServiceW

Alexander Yaworsky yaworsky at migusoft.ru
Tue Sep 14 02:40:35 CDT 2004


Hello

thank you for precept

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 14 Sep 2004 07:33:38 -0000
@@ -876,6 +876,8 @@
     HANDLE data,wait;
     PROCESS_INFORMATION procinfo;
     STARTUPINFOW startupinfo;
+    BOOL ret = FALSE;
+
     TRACE("(%p,%ld,%p)\n",hService,dwNumServiceArgs,
           lpServiceArgVectors);
 
@@ -934,19 +936,27 @@
     if(r == FALSE)
     {
         ERR("Couldn't start process\n");
-        /* ReleaseSemaphore(data, 1, NULL);
-        return FALSE; */
+        goto done;
     }
+    CloseHandle( procinfo.hThread );
 
     /* docs for StartServiceCtrlDispatcher say this should be 30 sec */
     r = WaitForSingleObject(wait,30000);
+    if( WAIT_FAILED == r )
+    {
+        CloseHandle( procinfo.hProcess );
+        goto done;
+    }
 
-    ReleaseSemaphore(data, 1, NULL);
-
-    if( r == WAIT_FAILED)
-        return FALSE;
+    /* allright */
+    CloseHandle( procinfo.hProcess );
+    ret = TRUE;
 
-    return TRUE;
+done:
+    CloseHandle( wait );
+    ReleaseSemaphore(data, 1, NULL);
+    CloseHandle( data );
+    return ret;
 }
 
 /******************************************************************************




More information about the wine-patches mailing list