- Send the SCM reply packet with the final status after completing the requested...
authorCameron Gutman <aicommander@gmail.com>
Sun, 28 Feb 2010 18:20:17 +0000 (18:20 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sun, 28 Feb 2010 18:20:17 +0000 (18:20 +0000)
 - Fixes the hang during 2nd stage setup

svn path=/trunk/; revision=45731

reactos/dll/win32/advapi32/service/sctrl.c

index a88fb2f..60516cd 100644 (file)
@@ -347,6 +347,8 @@ ScServiceDispatcher(HANDLE hPipe,
     DWORD dwRunningServices = 0;
     LPWSTR lpServiceName;
     PACTIVE_SERVICE lpService;
     DWORD dwRunningServices = 0;
     LPWSTR lpServiceName;
     PACTIVE_SERVICE lpService;
+    SCM_REPLY_PACKET ReplyPacket;
+    DWORD dwError;
 
     TRACE("ScDispatcherLoop() called\n");
 
 
     TRACE("ScDispatcherLoop() called\n");
 
@@ -381,22 +383,42 @@ ScServiceDispatcher(HANDLE hPipe,
             {
                 case SERVICE_CONTROL_START:
                     TRACE("Start command - recieved SERVICE_CONTROL_START\n");
             {
                 case SERVICE_CONTROL_START:
                     TRACE("Start command - recieved SERVICE_CONTROL_START\n");
-                    if (ScStartService(lpService, ControlPacket) == ERROR_SUCCESS)
+                    dwError = ScStartService(lpService, ControlPacket);
+                    if (dwError == ERROR_SUCCESS)
                         dwRunningServices++;
                     break;
 
                 case SERVICE_CONTROL_STOP:
                     TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n");
                         dwRunningServices++;
                     break;
 
                 case SERVICE_CONTROL_STOP:
                     TRACE("Stop command - recieved SERVICE_CONTROL_STOP\n");
-                    if (ScControlService(lpService, ControlPacket) == ERROR_SUCCESS)
+                    dwError = ScControlService(lpService, ControlPacket);
+                    if (dwError == ERROR_SUCCESS)
                         dwRunningServices--;
                     break;
 
                 default:
                     TRACE("Command %lu received", ControlPacket->dwControl);
                         dwRunningServices--;
                     break;
 
                 default:
                     TRACE("Command %lu received", ControlPacket->dwControl);
-                    ScControlService(lpService, ControlPacket);
-                    continue;
+                    dwError = ScControlService(lpService, ControlPacket);
+                    break;
             }
         }
             }
         }
+        else
+        {
+            dwError = ERROR_NOT_FOUND;
+        }
+
+        ReplyPacket.dwError = dwError;
+
+        /* Send the reply packet */
+        bResult = WriteFile(hPipe,
+                            &ReplyPacket,
+                            sizeof(ReplyPacket),
+                            &Count,
+                            NULL);
+        if (bResult == FALSE)
+        {
+            ERR("Pipe write failed (Error: %lu)\n", GetLastError());
+            return FALSE;
+        }
 
         if (dwRunningServices == 0)
             break;
 
         if (dwRunningServices == 0)
             break;