From 8eed1b3fc3d4e3261a68855ccc54c35102738a79 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 21 Dec 2018 16:16:46 +0100 Subject: irmd: Manage shm_flow_set from IRMd This moves the creation and destruction of shm_flow_set shared memory structures from the init to the IRMd. Now the management of all shared data objects is performed by the IRMd. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/proc_table.c | 55 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'src/irmd/proc_table.c') diff --git a/src/irmd/proc_table.c b/src/irmd/proc_table.c index 6f9d8e20..27fbb505 100644 --- a/src/irmd/proc_table.c +++ b/src/irmd/proc_table.c @@ -50,41 +50,44 @@ struct proc_entry * proc_entry_create(pid_t pid, e = malloc(sizeof(*e)); if (e == NULL) - return NULL; + goto fail_malloc; - list_head_init(&e->next); - list_head_init(&e->names); - - e->pid = pid; - e->prog = prog; - e->daf_name = NULL; - - e->re = NULL; - - e->state = PROC_INIT; - - if (pthread_condattr_init(&cattr)) { - free(e); - return NULL; - } + if (pthread_condattr_init(&cattr)) + goto fail_condattr; #ifndef __APPLE__ pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK); #endif - if (pthread_mutex_init(&e->lock, NULL)) { - free(e); - return NULL; - } + if (pthread_mutex_init(&e->lock, NULL)) + goto fail_mutex; + if (pthread_cond_init(&e->cond, &cattr)) + goto fail_cond; - if (pthread_cond_init(&e->cond, &cattr)) { - pthread_mutex_destroy(&e->lock); - free(e); - return NULL; - } + e->set = shm_flow_set_create(pid); + if (e->set == NULL) + goto fail_set; + + list_head_init(&e->next); + list_head_init(&e->names); + + e->pid = pid; + e->prog = prog; + e->re = NULL; + e->state = PROC_INIT; return e; + fail_set: + pthread_cond_destroy(&e->cond);; + fail_cond: + pthread_mutex_destroy(&e->lock); + fail_mutex: + pthread_condattr_destroy(&cattr); + fail_condattr: + free(e); + fail_malloc: + return NULL; } static void cancel_proc_entry(void * o) @@ -124,6 +127,8 @@ void proc_entry_destroy(struct proc_entry * e) pthread_mutex_unlock(&e->lock); + shm_flow_set_destroy(e->set); + pthread_cond_destroy(&e->cond); pthread_mutex_destroy(&e->lock); -- cgit v1.2.3