From 490ff55829df88fd57a1fa50f5e75b36faa4035a Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 25 Apr 2018 12:33:30 +0200 Subject: lib: Unlink old flow set shared memory This unlinks previously allocated flow set shared memory. It could be lingering in case an application with the same pid was SIGKILLED, and didn't clean up its flow set shared memory. Signed-off-by: Sander Vrijders Signed-off-by: Dimitri Staessens --- src/lib/shm_flow_set.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/shm_flow_set.c b/src/lib/shm_flow_set.c index 9d0e6c83..ca3a1a87 100644 --- a/src/lib/shm_flow_set.c +++ b/src/lib/shm_flow_set.c @@ -84,9 +84,13 @@ struct shm_flow_set * shm_flow_set_create() mode_t mask; int shm_fd; int i; + struct stat st; sprintf(fn, SHM_FLOW_SET_PREFIX "%d", getpid()); + if (stat(fn, &st) != -1 && unlink(fn)) + return NULL; + set = malloc(sizeof(*set)); if (set == NULL) return NULL; -- cgit v1.2.3