Refactor IRP_MJ_CLOSE TransitionLock unlocking
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
9ee4310026
commit
5c2a9a991e
6
wintun.c
6
wintun.c
@ -854,13 +854,13 @@ static NTSTATUS TunDispatch(DEVICE_OBJECT *DeviceObject, IRP *Irp)
|
|||||||
case IRP_MJ_CLOSE:
|
case IRP_MJ_CLOSE:
|
||||||
irql = ExAcquireSpinLockExclusive(&ctx->TransitionLock);
|
irql = ExAcquireSpinLockExclusive(&ctx->TransitionLock);
|
||||||
ASSERT(InterlockedGet64(&ctx->Device.RefCount) > 0);
|
ASSERT(InterlockedGet64(&ctx->Device.RefCount) > 0);
|
||||||
if (InterlockedDecrement64(&ctx->Device.RefCount) <= 0) {
|
BOOLEAN last_handle = InterlockedDecrement64(&ctx->Device.RefCount) <= 0;
|
||||||
ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql);
|
ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql);
|
||||||
|
if (last_handle) {
|
||||||
if (ctx->MiniportAdapterHandle)
|
if (ctx->MiniportAdapterHandle)
|
||||||
TunIndicateStatus(ctx->MiniportAdapterHandle, MediaConnectStateDisconnected);
|
TunIndicateStatus(ctx->MiniportAdapterHandle, MediaConnectStateDisconnected);
|
||||||
TunQueueClear(ctx, NDIS_STATUS_SEND_ABORTED);
|
TunQueueClear(ctx, NDIS_STATUS_SEND_ABORTED);
|
||||||
} else
|
}
|
||||||
ExReleaseSpinLockExclusive(&ctx->TransitionLock, irql);
|
|
||||||
IoReleaseRemoveLock(&ctx->Device.RemoveLock, stack->FileObject);
|
IoReleaseRemoveLock(&ctx->Device.RemoveLock, stack->FileObject);
|
||||||
|
|
||||||
status = STATUS_SUCCESS;
|
status = STATUS_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user