[PATCH] winedevice: Wait until driver has started before returning
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sat Mar 24 18:37:48 CDT 2018
Fixes: https://bugs.winehq.org/show_bug.cgi?id=38836
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
programs/winedevice/device.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index 397676d4c0..9da34ec145 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 );
--
2.16.2
More information about the wine-devel
mailing list