windows-nt/Source/XPSP1/NT/drivers/storage/iscsiprt/client/lock.c
2020-09-26 16:20:57 +08:00

69 lines
1.2 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (C) Microsoft Corporation, 2000
Module Name:
lock.c
Abstract:
This file contains code iSCSI Port driver
Environment:
kernel mode only
Revision History:
--*/
#include "port.h"
ULONG
iSpAcquireRemoveLock(
IN PDEVICE_OBJECT DeviceObject,
IN OPTIONAL PVOID Tag
)
{
PCOMMON_EXTENSION commonExtension = DeviceObject->DeviceExtension;
LONG lockValue;
lockValue = InterlockedIncrement(&(commonExtension->RemoveLock));
ASSERTMSG("iSpAcquireRemoveLock : lock value was negative ",
(lockValue > 0));
return (commonExtension->IsRemoved);
}
VOID
iSpReleaseRemoveLock(
IN PDEVICE_OBJECT DeviceObject,
IN OPTIONAL PVOID Tag
)
{
PCOMMON_EXTENSION commonExtension = DeviceObject->DeviceExtension;
LONG lockValue;
lockValue = InterlockedDecrement(&(commonExtension->RemoveLock));
if (lockValue < 0) {
ASSERTMSG("iSpReleaseRemoveLock : lock value was negative ",
(lockValue >= 0));
}
if (lockValue == 0) {
DebugPrint((3, "Releaselock for device object %x\n",
DeviceObject));
KeSetEvent(&(commonExtension->RemoveEvent),
IO_NO_INCREMENT,
FALSE);
}
return;
}