Fixed thread handling.
authorArmin Novak <anovak@thinstuff.com>
Thu, 5 Sep 2013 11:38:56 +0000 (13:38 +0200)
committerArmin Novak <anovak@thinstuff.com>
Thu, 5 Sep 2013 11:38:56 +0000 (13:38 +0200)
channels/printer/client/printer_main.c

index 3826b7c..b3b17fb 100644 (file)
@@ -200,6 +200,8 @@ static void* printer_thread_func(void* arg)
                printer_process_irp(printer_dev, irp);
        }
 
+       ExitThread(0);
+
        return NULL;
 }
 
@@ -219,11 +221,14 @@ static void printer_free(DEVICE* device)
 
        SetEvent(printer_dev->stopEvent);
        WaitForSingleObject(printer_dev->thread, INFINITE);
-       CloseHandle(printer_dev->thread);
 
        while ((irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL)
                irp->Discard(irp);
 
+       CloseHandle(printer_dev->thread);
+       CloseHandle(printer_dev->stopEvent);
+       CloseHandle(printer_dev->event);
+
        _aligned_free(printer_dev->pIrpList);
 
        if (printer_dev->printer)