From c5d78becce07858ec75fcabb6aa39f86ed1dc289 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Tue, 21 Mar 2023 08:33:22 +0300 Subject: [PATCH] Driver: fortstat: Simplify fort_flow_delete() --- src/driver/fortstat.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/driver/fortstat.c b/src/driver/fortstat.c index 8a7a36f2..59fe7f72 100644 --- a/src/driver/fortstat.c +++ b/src/driver/fortstat.c @@ -527,22 +527,27 @@ FORT_API NTSTATUS fort_flow_associate(PFORT_STAT stat, UINT64 flow_id, UINT32 pr return status; } +static BOOL fort_flow_delete_closing(PFORT_STAT stat) +{ + if ((fort_stat_flags(stat) & FORT_STAT_CLOSED) != 0) { + InterlockedDecrement(&stat->flow_closing_count); + return TRUE; + } + return FALSE; +} + FORT_API void fort_flow_delete(PFORT_STAT stat, UINT64 flowContext) { PFORT_FLOW flow = (PFORT_FLOW) flowContext; - if ((fort_stat_flags(stat) & FORT_STAT_CLOSED) != 0) { - InterlockedDecrement(&stat->flow_closing_count); + if (fort_flow_delete_closing(stat)) return; - } KLOCK_QUEUE_HANDLE lock_queue; KeAcquireInStackQueuedSpinLock(&stat->lock, &lock_queue); /* Double check for locked flows */ - if ((fort_stat_flags(stat) & FORT_STAT_CLOSED) != 0) { - InterlockedDecrement(&stat->flow_closing_count); - } else { + if (!fort_flow_delete_closing(stat)) { fort_flow_free(stat, flow); }