Skip to content

Commit

Permalink
sys - Remove timeout keepalive logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Liryna committed Dec 30, 2021
1 parent 0894632 commit c167bfc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
1 change: 0 additions & 1 deletion sys/dokan.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ typedef struct _DokanDiskControlBlock {

ULONG MountId;
ULONG Flags;
LARGE_INTEGER TickCount;

CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks;
Expand Down
35 changes: 2 additions & 33 deletions sys/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,6 @@ VOID DokanUnmount(__in_opt PREQUEST_CONTEXT RequestContext, __in PDokanDCB Dcb)
DOKAN_LOG("End");
}

VOID DokanCheckKeepAlive(__in PDokanDCB Dcb) {
LARGE_INTEGER tickCount;
PDokanVCB vcb;

KeEnterCriticalRegion();
KeQueryTickCount(&tickCount);
ExAcquireResourceSharedLite(&Dcb->Resource, TRUE);

if (Dcb->TickCount.QuadPart < tickCount.QuadPart) {
vcb = Dcb->Vcb;
ExReleaseResourceLite(&Dcb->Resource);
DOKAN_LOG("Timeout reached so perform an umount");
if (IsUnmountPendingVcb(vcb)) {
DOKAN_LOG("Volume is not mounted");
KeLeaveCriticalRegion();
return;
}
DokanUnmount(NULL, Dcb);
} else {
ExReleaseResourceLite(&Dcb->Resource);
}
KeLeaveCriticalRegion();
}

NTSTATUS
ReleaseTimeoutPendingIrp(__in PDokanDCB Dcb) {
KIRQL oldIrql;
Expand Down Expand Up @@ -245,7 +221,6 @@ Routine Description:
BOOLEAN waitObj = TRUE;
LARGE_INTEGER LastTime = {0};
LARGE_INTEGER CurrentTime = {0};
PDokanVCB vcb;
PDokanDCB Dcb = pDcb;
DOKAN_INIT_LOGGER(logger, Dcb->DeviceObject->DriverObject, 0);

Expand All @@ -257,8 +232,6 @@ Routine Description:
pollevents[1] = (PVOID)&Dcb->ForceTimeoutEvent;
pollevents[2] = (PVOID)&timer;

vcb = Dcb->Vcb;

KeSetTimerEx(&timer, timeout, DOKAN_CHECK_INTERVAL, NULL);

KeQuerySystemTime(&LastTime);
Expand All @@ -273,19 +246,15 @@ Routine Description:
waitObj = FALSE;
} else {
KeClearEvent(&Dcb->ForceTimeoutEvent);
// in this case the timer was executed and we are checking if the timer
// In this case the timer was executed and we are checking if the timer
// occurred regulary using the period DOKAN_CHECK_INTERVAL. If not, this
// means the system was in sleep mode. If in this case the timer is
// faster awaken than the incoming IOCTL_KEEPALIVE
// the MountPoint would be removed by mistake (DokanCheckKeepAlive).
// means the system was in sleep mode.
KeQuerySystemTime(&CurrentTime);
if ((CurrentTime.QuadPart - LastTime.QuadPart) >
((DOKAN_CHECK_INTERVAL + 2000) * 10000)) {
DokanLogInfo(&logger, L"Wake from sleep detected.");
} else {
ReleaseTimeoutPendingIrp(Dcb);
if (!vcb->IsKeepaliveActive)
DokanCheckKeepAlive(Dcb); //Remove for Dokan 2.x.x
}
KeQuerySystemTime(&LastTime);
}
Expand Down

0 comments on commit c167bfc

Please sign in to comment.