[phodav: 5/14] spice: quit service quickly



commit 6e75a1b16306d9dceaf81c8df9e2bd83a8ca7c34
Author: Jakub Janků <jjanku redhat com>
Date:   Sat May 11 14:04:16 2019 +0200

    spice: quit service quickly
    
    We shouldn't wait for 1 second if the service is supposed to stop.
    
    Signed-off-by: Jakub Janků <jjanku redhat com>

 spice/spice-webdavd.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
index 674a582..826e2d6 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -932,11 +932,15 @@ map_drive_cb(GTask *task,
 
 #endif
 
-static void
+/* returns FALSE if the service should quit */
+static gboolean
 run_service (ServiceData *service_data)
 {
   g_debug ("Run service");
 
+  if (quit_service)
+    return FALSE;
+
 #ifdef G_OS_WIN32
   MapDriveData map_drive_data;
   map_drive_data.cancel_map = g_cancellable_new ();
@@ -1012,6 +1016,7 @@ run_service (ServiceData *service_data)
 #else
   close (port_fd);
 #endif
+  return !quit_service;
 }
 
 #ifdef G_OS_WIN32
@@ -1073,9 +1078,8 @@ service_main (DWORD argc, TCHAR *argv[])
   service_status.dwWaitHint = 0;
   SetServiceStatus (service_status_handle, &service_status);
 
-  while (!quit_service) {
-      run_service (&service_data);
-      g_usleep (G_USEC_PER_SEC);
+  while (run_service(&service_data)) {
+    g_usleep(G_USEC_PER_SEC);
   }
 
   service_status.dwCurrentState = SERVICE_STOPPED;
@@ -1167,8 +1171,7 @@ main (int argc, char *argv[])
         }
     } else
 #endif
-  while (!quit_service) {
-    run_service (&service_data);
+  while (run_service(&service_data)) {
     g_usleep (G_USEC_PER_SEC);
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]