[Spice-devel] [PATCHv2 win-agent 7/9] Allow running as a normal process again

Marc-André Lureau marcandre.lureau at gmail.com
Wed May 16 11:15:31 PDT 2012


The service code should be commented out if DEBUG_VDSERVICE.
Otherwise it fails to run as a standalone process.
---
 vdservice/vdservice.cpp |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 48ebd7b..e6b707e 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -412,13 +412,12 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     status->dwServiceSpecificExitCode = NO_ERROR;
     status->dwCheckPoint = 0;
     status->dwWaitHint = 0;
+#ifndef  DEBUG_VDSERVICE
     s->_status_handle = RegisterServiceCtrlHandlerEx(VD_SERVICE_NAME, &VDService::control_handler,
                                                      NULL);
     if (!s->_status_handle) {
-        printf("RegisterServiceCtrlHandler failed\n");
-#ifndef DEBUG_VDSERVICE
+        vd_printf("RegisterServiceCtrlHandler failed\n");
         return;
-#endif // DEBUG_VDSERVICE
     }
 
     // service is starting
@@ -429,10 +428,12 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     status->dwControlsAccepted |= VDSERVICE_ACCEPTED_CONTROLS;
     status->dwCurrentState = SERVICE_RUNNING;
     SetServiceStatus(s->_status_handle, status);
+#endif //DEBUG_VDSERVICE
 
     s->_running = true;
     s->execute();
 
+#ifndef  DEBUG_VDSERVICE
     // service was stopped
     status->dwCurrentState = SERVICE_STOP_PENDING;
     SetServiceStatus(s->_status_handle, status);
@@ -440,7 +441,6 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
     // service is stopped
     status->dwControlsAccepted &= ~VDSERVICE_ACCEPTED_CONTROLS;
     status->dwCurrentState = SERVICE_STOPPED;
-#ifndef DEBUG_VDSERVICE
     SetServiceStatus(s->_status_handle, status);
 #endif //DEBUG_VDSERVICE
     vd_printf("***Service stopped***");
-- 
1.7.10.1



More information about the Spice-devel mailing list