summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf_apps.c
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_apps.c')
-rw-r--r--collectors/ebpf.plugin/ebpf_apps.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/collectors/ebpf.plugin/ebpf_apps.c b/collectors/ebpf.plugin/ebpf_apps.c
index 844ce23b8..1be7b9260 100644
--- a/collectors/ebpf.plugin/ebpf_apps.c
+++ b/collectors/ebpf.plugin/ebpf_apps.c
@@ -910,6 +910,26 @@ static inline void del_pid_entry(pid_t pid)
}
/**
+ * Cleanup variable from other threads
+ *
+ * @param pid current pid.
+ */
+void cleanup_variables_from_other_threads(uint32_t pid)
+{
+ // Clean socket structures
+ if (socket_bandwidth_curr) {
+ freez(socket_bandwidth_curr[pid]);
+ socket_bandwidth_curr[pid] = NULL;
+ }
+
+ // Clean cachestat strcture
+ if (cachestat_pid) {
+ freez(cachestat_pid[pid]);
+ cachestat_pid[pid] = NULL;
+ }
+}
+
+/**
* Remove PIDs when they are not running more.
*/
void cleanup_exited_pids()
@@ -932,11 +952,7 @@ void cleanup_exited_pids()
freez(current_apps_data[r]);
current_apps_data[r] = NULL;
- // Clean socket structures
- if (socket_bandwidth_curr) {
- freez(socket_bandwidth_curr[r]);
- socket_bandwidth_curr[r] = NULL;
- }
+ cleanup_variables_from_other_threads(r);
} else {
if (unlikely(p->keep))
p->keeploops++;
@@ -1054,11 +1070,7 @@ void collect_data_for_all_processes(int tbl_pid_stats_fd)
freez(current_apps_data[key]);
current_apps_data[key] = NULL;
- // Clean socket structures
- if (socket_bandwidth_curr) {
- freez(socket_bandwidth_curr[key]);
- socket_bandwidth_curr[key] = NULL;
- }
+ cleanup_variables_from_other_threads(key);
pids = pids->next;
continue;