[Spice-devel] [PATCH phodav 04/13] spice: quit service quickly
Jakub Janků
jjanku at redhat.com
Thu May 23 08:37:16 UTC 2019
We shouldn't wait for 1 second if the service is supposed to stop.
Signed-off-by: Jakub Janků <jjanku at 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 cdfa73d..6ad63c5 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -923,11 +923,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 ();
@@ -1003,6 +1007,7 @@ run_service (ServiceData *service_data)
#else
close (port_fd);
#endif
+ return !quit_service;
}
#ifdef G_OS_WIN32
@@ -1064,9 +1069,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;
@@ -1154,8 +1158,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);
}
--
2.21.0
More information about the Spice-devel
mailing list