[Wine-patches] winedevice: Stop when SERVICE_CONTROL_STOP is received.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Ноя 28 17:51:16 MSK 2008


Более корректное завершение сервиса
----------- следующая часть -----------
From b0e5016d4afbe3291471b3cb338cd5cbf4cf4edb Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 28 Nov 2008 17:38:55 +0300
Subject: [PATCH] winedevice: Stop when SERVICE_CONTROL_STOP is received.

---
 programs/winedevice/device.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index e6b11b0..301fe3d 100644
--- a/programs/winedevice/device.c
+++ b/programs/winedevice/device.c
@@ -295,25 +295,29 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
             PDEVICE_OBJECT pdev_obj = NULL;
             UCHAR pdo_info[2 * PATH_MAX + 3 + MAX_DEVICE_ID_LEN];
             data_size_t reply_size = 0;
+            HANDLE events[2] = {stop_event, NULL};
+            DWORD wait_ret;
 
             while (!reply_size)
             {
-                HANDLE event = NULL;
-
                 SERVER_START_REQ( get_add_device_request )
                 {
-                    req->event = event;
+                    req->event = events[1];
                     wine_server_add_data( req, drvname.Buffer, drvname.Length );
                     wine_server_set_reply( req, pdo_info, sizeof(pdo_info) );
                     ret = wine_server_call( req );
-                    event = reply->event;
+                    events[1] = reply->event;
                     if (STATUS_SUCCESS == ret)
                         reply_size = wine_server_reply_size( reply );
                 }
                 SERVER_END_REQ;
 
                 if (STATUS_PENDING == ret)
-                    WaitForSingleObject( event, INFINITE );
+                {
+                    wait_ret = WaitForMultipleObjects( 2, events, FALSE, INFINITE );
+                    if (wait_ret == WAIT_OBJECT_0)
+                        goto stop;
+                }
             }
 
             pdev_obj = __wine_usbhub_get_pdo( pdo_info );
@@ -362,7 +366,7 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
         wine_ntoskrnl_main_loop( stop_event );
     }
     else WINE_TRACE( "driver %s failed to load\n", wine_dbgstr_w(driver_name) );
-
+stop:
     status.dwCurrentState     = SERVICE_STOPPED;
     status.dwControlsAccepted = 0;
     SetServiceStatus( service_handle, &status );
-- 
1.6.0.2.GIT



Подробная информация о списке рассылки Wine-patches