Fixed resource leaks and missing thread sync.
This commit is contained in:
parent
1d2adcbe26
commit
755bd6980b
@ -44,8 +44,7 @@ static void smartcard_free(DEVICE* dev)
|
|||||||
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) dev;
|
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) dev;
|
||||||
|
|
||||||
SetEvent(smartcard->stopEvent);
|
SetEvent(smartcard->stopEvent);
|
||||||
CloseHandle(smartcard->thread);
|
WaitForSingleObject(smartcard->thread, INFINITE);
|
||||||
CloseHandle(smartcard->irpEvent);
|
|
||||||
|
|
||||||
while ((irp = (IRP*) InterlockedPopEntrySList(smartcard->pIrpList)) != NULL)
|
while ((irp = (IRP*) InterlockedPopEntrySList(smartcard->pIrpList)) != NULL)
|
||||||
irp->Discard(irp);
|
irp->Discard(irp);
|
||||||
@ -55,8 +54,14 @@ static void smartcard_free(DEVICE* dev)
|
|||||||
/* Begin TS Client defect workaround. */
|
/* Begin TS Client defect workaround. */
|
||||||
|
|
||||||
while ((CompletionIdInfo = (COMPLETIONIDINFO*) list_dequeue(smartcard->CompletionIds)) != NULL)
|
while ((CompletionIdInfo = (COMPLETIONIDINFO*) list_dequeue(smartcard->CompletionIds)) != NULL)
|
||||||
free(CompletionIdInfo);
|
free(CompletionIdInfo);
|
||||||
|
|
||||||
|
CloseHandle(smartcard->thread);
|
||||||
|
CloseHandle(smartcard->irpEvent);
|
||||||
|
CloseHandle(smartcard->stopEvent);
|
||||||
|
CloseHandle(smartcard->CompletionIdsMutex);
|
||||||
|
|
||||||
|
Stream_Free(smartcard->device.data, TRUE);
|
||||||
list_free(smartcard->CompletionIds);
|
list_free(smartcard->CompletionIds);
|
||||||
|
|
||||||
/* End TS Client defect workaround. */
|
/* End TS Client defect workaround. */
|
||||||
@ -119,13 +124,16 @@ static void smartcard_process_irp_thread_func(SMARTCARD_IRP_WORKER* irpWorker)
|
|||||||
static void* smartcard_thread_func(void* arg)
|
static void* smartcard_thread_func(void* arg)
|
||||||
{
|
{
|
||||||
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) arg;
|
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) arg;
|
||||||
|
HANDLE ev[] = {smartcard->irpEvent, smartcard->stopEvent};
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
WaitForSingleObject(smartcard->irpEvent, INFINITE);
|
DWORD status = WaitForSingleObject(2, ev, FALSE, INFINITE);
|
||||||
|
|
||||||
if (WaitForSingleObject(smartcard->stopEvent, 0) == WAIT_OBJECT_0)
|
if (status == WAIT_OBJECT_0 + 1)
|
||||||
break;
|
break;
|
||||||
|
else if(status != WAIT_OBJECT_0)
|
||||||
|
continue;
|
||||||
|
|
||||||
ResetEvent(smartcard->irpEvent);
|
ResetEvent(smartcard->irpEvent);
|
||||||
smartcard_process_irp_list(smartcard);
|
smartcard_process_irp_list(smartcard);
|
||||||
|
Loading…
Reference in New Issue
Block a user