diff options
author | Campus <campus@ntop.org> | 2016-02-16 12:23:56 +0100 |
---|---|---|
committer | Campus <campus@ntop.org> | 2016-02-16 12:23:56 +0100 |
commit | 84976ed5dc001050613667c172709e82f124f36d (patch) | |
tree | 80d8e7a904527929cae01c67f56f91c8e9f5622d /example/ndpiReader.c | |
parent | 15ccb70ae61509595a2b2611bdbc3a7a6416e5d7 (diff) |
fix for https://github.com/ntop/nDPI/issues/148
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 4d1ae1296..bb6ee81c8 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -1104,10 +1104,15 @@ static unsigned int packet_processing(u_int16_t thread_id, ndpi_twalk(ndpi_thread_info[thread_id].ndpi_flows_root[ndpi_thread_info[thread_id].idle_scan_idx], node_idle_scan_walker, &thread_id); /* remove idle flows (unfortunately we cannot do this inline) */ - while (ndpi_thread_info[thread_id].num_idle_flows > 0) - ndpi_tdelete(ndpi_thread_info[thread_id].idle_flows[--ndpi_thread_info[thread_id].num_idle_flows], - &ndpi_thread_info[thread_id].ndpi_flows_root[ndpi_thread_info[thread_id].idle_scan_idx], node_cmp); - + while (ndpi_thread_info[thread_id].num_idle_flows > 0) { + + /* search and delete the idle flow from the "ndpi_flow_root" (see struct reader thread) - here flows are the node of a b-tree */ + ndpi_tdelete(ndpi_thread_info[thread_id].idle_flows[--ndpi_thread_info[thread_id].num_idle_flows], &ndpi_thread_info[thread_id].ndpi_flows_root[ndpi_thread_info[thread_id].idle_scan_idx], node_cmp); + + /* free the memory associated to idle flow in "idle_flows" - (see struct reader thread)*/ + free_ndpi_flow(ndpi_thread_info[thread_id].idle_flows[ndpi_thread_info[thread_id].num_idle_flows]); + } + if(++ndpi_thread_info[thread_id].idle_scan_idx == NUM_ROOTS) ndpi_thread_info[thread_id].idle_scan_idx = 0; ndpi_thread_info[thread_id].last_idle_scan_time = ndpi_thread_info[thread_id].last_time; } |