advapi32/service.c; patch 7/7: Notify StartService when service has been started

Alexander Yaworsky yaworsky at migusoft.ru
Thu Nov 11 21:37:42 CST 2004


ChangeLog:

Notify StartService when service has been started.

diff -urN out1/dlls/advapi32/service.c out2/dlls/advapi32/service.c
--- out1/dlls/advapi32/service.c	2004-11-12 02:18:48.000000000 +0600
+++ out2/dlls/advapi32/service.c	2004-11-12 02:30:44.000000000 +0600
@@ -46,6 +46,9 @@
                                                  'M','U','X','_','%','s',0};
  static const WCHAR  szServiceAckEventNameFmtW[] = {'A','D','V','A','P','I','_',
                                                     'A','C','K','_','%','s',0};
+static const WCHAR  szWaitServiceStartW[]  = {'A','D','V','A','P','I','_','W',
+                                              'a','i','t','S','e','r','v','i',
+                                              'c','e','S','t','a','r','t',0};

  struct SEB              /* service environment block */
  {                       /*   resides in service's shared memory object */
@@ -344,6 +347,15 @@
  static DWORD WINAPI service_thread( LPVOID arg )
  {
      struct service_thread_data *data = arg;
+    HANDLE wait;
+
+    /* signal for StartService */
+    wait = OpenSemaphoreW( SEMAPHORE_MODIFY_STATE, FALSE, szWaitServiceStartW );
+    if( wait )
+    {
+        ReleaseSemaphore( wait, 1, NULL );
+        CloseHandle( wait );
+    }

      data->service_main( data->argc, data->argv );
      data->terminated = TRUE;
@@ -1225,9 +1237,6 @@
  StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs,
                   LPCWSTR *lpServiceArgVectors )
  {
-    static const WCHAR  _WaitServiceStartW[]  = {'A','D','V','A','P','I','_','W',
-                                                'a','i','t','S','e','r','v','i',
-                                                'c','e','S','t','a','r','t',0};
      static const WCHAR  _ImagePathW[]  = {'I','m','a','g','e','P','a','t','h',0};

      struct sc_handle *hsvc = hService;
@@ -1308,7 +1317,7 @@
          argptr += 1 + strlenW( argptr );
      }

-    wait = CreateSemaphoreW(NULL,0,1,_WaitServiceStartW);
+    wait = CreateSemaphoreW(NULL,0,1,szWaitServiceStartW);
      if (!wait)
      {
          ERR("Couldn't create wait semaphore\n");
@@ -1343,6 +1352,13 @@
          CloseHandle( procinfo.hProcess );
          goto done;
      }
+    if( WAIT_TIMEOUT == r )
+    {
+        TerminateProcess( procinfo.hProcess, 1 );
+        CloseHandle( procinfo.hProcess );
+        SetLastError( ERROR_SERVICE_REQUEST_TIMEOUT );
+        goto done;
+    }

      /* allright */
      CloseHandle( procinfo.hProcess );




More information about the wine-patches mailing list