diff options
author | Dimitri Staessens <[email protected]> | 2018-12-21 16:16:46 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2018-12-22 10:20:31 +0100 |
commit | 8eed1b3fc3d4e3261a68855ccc54c35102738a79 (patch) | |
tree | 28cbf1e57f267330aae761fa27d47821f7954fb4 /src/irmd/proc_table.c | |
parent | 933aa5ab479732d84b3331ef4638dd9be07695b2 (diff) | |
download | ouroboros-8eed1b3fc3d4e3261a68855ccc54c35102738a79.tar.gz ouroboros-8eed1b3fc3d4e3261a68855ccc54c35102738a79.zip |
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 <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd/proc_table.c')
-rw-r--r-- | src/irmd/proc_table.c | 55 |
1 files changed, 30 insertions, 25 deletions
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); |