diff options
author | ol-andreyizrailev <62878213+ol-andreyizrailev@users.noreply.github.com> | 2022-02-09 13:43:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-09 11:43:10 +0100 |
commit | 8cc5cb9f767119f7219c918843893bdeaa98d909 (patch) | |
tree | 62a785e9c1a44872d21e92dc9d6b657b13e1f8e4 /example | |
parent | 9838ceb7cd210b748cd236f198e54d846c169fa0 (diff) |
Increment current/total number of active flows on successful flow insertion (#1434)
Memory allocation or ndpi_tsearch might fail, so the two values should be
incremented only when insertion actually happened.
Co-authored-by: Andrey Izrailev <Andrey.Izrailev@oktetlabs.ru>
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpiSimpleIntegration.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/example/ndpiSimpleIntegration.c b/example/ndpiSimpleIntegration.c index 57b51450c..303917a1b 100644 --- a/example/ndpiSimpleIntegration.c +++ b/example/ndpiSimpleIntegration.c @@ -776,8 +776,6 @@ static void ndpi_process_packet(uint8_t * const args, return; } - workflow->cur_active_flows++; - workflow->total_active_flows++; memcpy(flow_to_process, &flow, sizeof(*flow_to_process)); flow_to_process->flow_id = __sync_fetch_and_add(&flow_id, 1); @@ -796,6 +794,9 @@ static void ndpi_process_packet(uint8_t * const args, /* Possible Leak, but should not happen as we'd abort earlier. */ return; } + + workflow->cur_active_flows++; + workflow->total_active_flows++; } else { flow_to_process = *(struct nDPI_flow_info **)tree_result; } |