mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:06:08 +00:00
Driver: fortstat: Don't remove process from map when iterating it
This commit is contained in:
parent
af927793b2
commit
a3697289d0
@ -61,13 +61,18 @@ static PFORT_STAT_PROC fort_stat_proc_get(PFORT_STAT stat, UINT32 process_id, to
|
|||||||
|
|
||||||
static void fort_stat_proc_free(PFORT_STAT stat, PFORT_STAT_PROC proc)
|
static void fort_stat_proc_free(PFORT_STAT stat, PFORT_STAT_PROC proc)
|
||||||
{
|
{
|
||||||
tommy_hashdyn_remove_existing(&stat->procs_map, (tommy_hashdyn_node *) proc);
|
|
||||||
|
|
||||||
/* Add to free chain */
|
/* Add to free chain */
|
||||||
proc->next = stat->proc_free;
|
proc->next = stat->proc_free;
|
||||||
stat->proc_free = proc;
|
stat->proc_free = proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fort_stat_proc_del(PFORT_STAT stat, PFORT_STAT_PROC proc)
|
||||||
|
{
|
||||||
|
tommy_hashdyn_remove_existing(&stat->procs_map, (tommy_hashdyn_node *) proc);
|
||||||
|
|
||||||
|
fort_stat_proc_free(stat, proc);
|
||||||
|
}
|
||||||
|
|
||||||
static PFORT_STAT_PROC fort_stat_proc_add(PFORT_STAT stat, UINT32 process_id)
|
static PFORT_STAT_PROC fort_stat_proc_add(PFORT_STAT stat, UINT32 process_id)
|
||||||
{
|
{
|
||||||
const tommy_key_t proc_hash = fort_stat_proc_hash(process_id);
|
const tommy_key_t proc_hash = fort_stat_proc_hash(process_id);
|
||||||
@ -445,9 +450,17 @@ static void fort_stat_clear(PFORT_STAT stat)
|
|||||||
KLOCK_QUEUE_HANDLE lock_queue;
|
KLOCK_QUEUE_HANDLE lock_queue;
|
||||||
KeAcquireInStackQueuedSpinLock(&stat->lock, &lock_queue);
|
KeAcquireInStackQueuedSpinLock(&stat->lock, &lock_queue);
|
||||||
|
|
||||||
|
/* Clear processes active list */
|
||||||
fort_stat_proc_active_clear(stat);
|
fort_stat_proc_active_clear(stat);
|
||||||
|
|
||||||
|
/* Clear processes map */
|
||||||
|
if (tommy_hashdyn_count(&stat->procs_map) > 0) {
|
||||||
tommy_hashdyn_foreach_node_arg(&stat->procs_map, &fort_stat_proc_free, stat);
|
tommy_hashdyn_foreach_node_arg(&stat->procs_map, &fort_stat_proc_free, stat);
|
||||||
|
tommy_hashdyn_done(&stat->procs_map);
|
||||||
|
tommy_hashdyn_init(&stat->procs_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close flows */
|
||||||
tommy_hashdyn_foreach_node(&stat->flows_map, &fort_flow_close);
|
tommy_hashdyn_foreach_node(&stat->flows_map, &fort_flow_close);
|
||||||
|
|
||||||
KeReleaseInStackQueuedSpinLock(&lock_queue);
|
KeReleaseInStackQueuedSpinLock(&lock_queue);
|
||||||
@ -609,7 +622,7 @@ FORT_API void fort_stat_dpc_traf_flush(PFORT_STAT stat, UINT16 proc_count, PCHAR
|
|||||||
/* The process is inactive */
|
/* The process is inactive */
|
||||||
*out_proc |= 1;
|
*out_proc |= 1;
|
||||||
|
|
||||||
fort_stat_proc_free(stat, proc);
|
fort_stat_proc_del(stat, proc);
|
||||||
} else {
|
} else {
|
||||||
proc->active = FALSE;
|
proc->active = FALSE;
|
||||||
|
|
||||||
|
@ -25,17 +25,17 @@ typedef struct fort_stat_proc
|
|||||||
|
|
||||||
tommy_key_t proc_hash; /* tommy_hashdyn_node::index */
|
tommy_key_t proc_hash; /* tommy_hashdyn_node::index */
|
||||||
|
|
||||||
UINT16 proc_index : 15; /* Synchronize with FORT_PROC_COUNT_MAX! */
|
|
||||||
UINT16 active : 1;
|
|
||||||
|
|
||||||
UINT16 refcount;
|
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
UINT32 process_id;
|
UINT32 process_id;
|
||||||
#else
|
#else
|
||||||
FORT_TRAF traf;
|
FORT_TRAF traf;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
UINT16 proc_index : 15; /* Synchronize with FORT_PROC_COUNT_MAX! */
|
||||||
|
UINT16 active : 1;
|
||||||
|
|
||||||
|
UINT16 refcount;
|
||||||
|
|
||||||
struct fort_stat_proc *next_active;
|
struct fort_stat_proc *next_active;
|
||||||
} FORT_STAT_PROC, *PFORT_STAT_PROC;
|
} FORT_STAT_PROC, *PFORT_STAT_PROC;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user