[Wine-patches] Wait for loading USB device drivers.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пн Мар 30 19:40:25 MSD 2009


Патч решает проблему, описанную в баге 3721.
----------- следующая часть -----------
From 25120d6ed3e50153ba586f5f57544864ffe0d75a Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Mon, 30 Mar 2009 19:12:50 +0400
Subject: [PATCH] Wait for loading USB device drivers.

---
 dlls/usbhub.sys/usbhub.c     |    7 +++++++
 programs/services/services.c |    9 +++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 9a5bb27..6dae806 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -487,6 +487,9 @@ fail:
 static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
 {
     static const WCHAR grdkeyW[] = {'G','r','d','K','e','y',0};
+    static const WCHAR usbhub_started_eventW[] = {'_','_','w','i','n','e',
+                                                  '_','U','s','b','h','u','b',
+                                                  'S','t','a','r','t','e','d',0};
 
     struct DeviceInstance *instance;
     struct usb_device *dev;
@@ -495,6 +498,7 @@ static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
     DRIVER_OBJECT *driver;
     DRIVER_OBJECT *hubdrv = usbhubdrv;
     NTSTATUS status;
+    HANDLE event;
 
     if (!enum_reg_usb_devices())
     {
@@ -543,6 +547,9 @@ static DWORD CALLBACK enum_usb_devices( void *usbhubdrv )
                 }
             }
 
+    event = CreateEventW( NULL, TRUE, FALSE, usbhub_started_eventW );
+    SetEvent( event );
+    CloseHandle( event );
     return 0;
 }
 #endif
diff --git a/programs/services/services.c b/programs/services/services.c
index b6f8a2c..a15a105 100644
--- a/programs/services/services.c
+++ b/programs/services/services.c
@@ -223,6 +223,9 @@ DWORD scmdatabase_remove_service(struct scmdatabase *db, struct service_entry *s
 
 static void scmdatabase_autostart_services(struct scmdatabase *db)
 {
+    static const WCHAR usbhub_started_event[] = {'_','_','w','i','n','e',
+        '_','U','s','b','h','u','b','S','t','a','r','t','e','d',0};
+    static const WCHAR usbhub[] = {'U','s','b','h','u','b',0};
     struct service_entry **services_list;
     unsigned int i = 0;
     unsigned int size = 32;
@@ -267,6 +270,12 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
         argv[1] = NULL;
         err = service_start(service, 1, argv);
         /* FIXME: do something if the service failed to start */
+        if (!strcmpW(service->name, usbhub))
+        {
+            HANDLE event = CreateEventW(NULL, TRUE, FALSE, usbhub_started_event);
+            WaitForSingleObject(event, 30000);
+            CloseHandle(event);
+        }
         release_service(service);
     }
 
-- 
1.6.1.3.GIT



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