Merge pull request #1405 from akallabeth/printer_stop_fix

Fix hang on shutdown with printer redirection
This commit is contained in:
Marc-André Moreau 2013-08-14 06:54:15 -07:00
commit 729f73d52b

View File

@ -179,13 +179,16 @@ static void* printer_thread_func(void* arg)
{ {
IRP* irp; IRP* irp;
PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) arg; PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*) arg;
HANDLE obj[] = {printer_dev->event, printer_dev->stopEvent};
while (1) while (1)
{ {
WaitForSingleObject(printer_dev->event, INFINITE); DWORD rc = WaitForMultipleObjects(2, obj, FALSE, INFINITE);
if (WaitForSingleObject(printer_dev->stopEvent, 0) == WAIT_OBJECT_0) if (rc == WAIT_OBJECT_0 + 1)
break; break;
else if( rc != WAIT_OBJECT_0 )
continue;
ResetEvent(printer_dev->event); ResetEvent(printer_dev->event);