Re: [Spice-devel] [PATCH phodav 04/13] spice: quit service quickly

2019-05-23 Thread Marc-André Lureau
On Thu, May 23, 2019 at 10:37 AM Jakub Janků  wrote:
>
> We shouldn't wait for 1 second if the service is supposed to stop.
>
> Signed-off-by: Jakub Janků 

ack

> ---
>  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, _status);
>
> -  while (!quit_service) {
> -  run_service (_data);
> -  g_usleep (G_USEC_PER_SEC);
> +  while (run_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 (_data);
> +  while (run_service(_data)) {
>  g_usleep (G_USEC_PER_SEC);
>}
>
> --
> 2.21.0
>
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Spice-devel] [PATCH phodav 04/13] spice: quit service quickly

2019-05-23 Thread Jakub Janků
We shouldn't wait for 1 second if the service is supposed to stop.

Signed-off-by: Jakub Janků 
---
 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, _status);
 
-  while (!quit_service) {
-  run_service (_data);
-  g_usleep (G_USEC_PER_SEC);
+  while (run_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 (_data);
+  while (run_service(_data)) {
 g_usleep (G_USEC_PER_SEC);
   }
 
-- 
2.21.0

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel