Module: wine Branch: stable Commit: ae347f99a40c35ce526cd689d99bdec8c29a3700 URL: https://source.winehq.org/git/wine.git/?a=commit;h=ae347f99a40c35ce526cd689d...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Sat Mar 24 23:37:48 2018 +0000
winedevice: Wait until driver has started before returning.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 57268241f745686e86bae41f44214bd05f98c723) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
programs/winedevice/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c index 397676d..9da34ec 100644 --- a/programs/winedevice/device.c +++ b/programs/winedevice/device.c @@ -55,6 +55,7 @@ struct wine_driver struct wine_rb_entry entry;
SERVICE_STATUS_HANDLE handle; + HANDLE started; DRIVER_OBJECT *driver_obj; WCHAR name[1]; }; @@ -390,6 +391,8 @@ static void WINAPI async_create_driver( PTP_CALLBACK_INSTANCE instance, void *co goto error; }
+ SetEvent(driver->started); + EnterCriticalSection( &drivers_cs ); driver->driver_obj = driver_obj; set_service_status( driver->handle, SERVICE_RUNNING, @@ -441,10 +444,16 @@ static NTSTATUS create_driver( const WCHAR *driver_name ) environment.Version = 1; environment.CleanupGroup = cleanup_group;
+ driver->started = CreateEventW(NULL, TRUE, FALSE, NULL); + /* don't block the service control handler */ if (!TrySubmitThreadpoolCallback( async_create_driver, driver, &environment )) async_create_driver( NULL, driver );
+ /* Windows wait 30 Seconds */ + if(WaitForSingleObject(driver->started, 30000) == WAIT_TIMEOUT) + return ERROR_SERVICE_REQUEST_TIMEOUT; + return STATUS_SUCCESS; }
@@ -453,6 +462,7 @@ static void wine_drivers_rb_destroy( struct wine_rb_entry *entry, void *context if (unload_driver( entry, TRUE ) != STATUS_SUCCESS) { struct wine_driver *driver = WINE_RB_ENTRY_VALUE( entry, struct wine_driver, entry ); + CloseHandle(driver->started); ObDereferenceObject( driver->driver_obj ); CloseServiceHandle( (void *)driver->handle ); HeapFree( GetProcessHeap(), 0, driver );