diff options
Diffstat (limited to 'src/irmd')
-rw-r--r-- | src/irmd/proc_table.c | 55 | ||||
-rw-r--r-- | src/irmd/proc_table.h | 21 |
2 files changed, 41 insertions, 35 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); diff --git a/src/irmd/proc_table.h b/src/irmd/proc_table.h index f3ef9aff..a18b0d8c 100644 --- a/src/irmd/proc_table.h +++ b/src/irmd/proc_table.h @@ -23,7 +23,8 @@ #ifndef OUROBOROS_IRMD_PROC_TABLE_H #define OUROBOROS_IRMD_PROC_TABLE_H -#include "time.h" +#include <ouroboros/shm_flow_set.h> + #include "utils.h" #include <unistd.h> @@ -38,18 +39,18 @@ enum proc_state { }; struct proc_entry { - struct list_head next; - pid_t pid; - char * prog; /* program instantiated */ - char * daf_name; /* DAF this process belongs to */ - struct list_head names; /* names for which process accepts flows */ + struct list_head next; + pid_t pid; + char * prog; /* program instantiated */ + struct list_head names; /* names for which process accepts flows */ + struct shm_flow_set * set; - struct reg_entry * re; /* reg_entry for which a flow arrived */ + struct reg_entry * re; /* reg_entry for which a flow arrived */ /* The process will block on this */ - enum proc_state state; - pthread_cond_t cond; - pthread_mutex_t lock; + enum proc_state state; + pthread_cond_t cond; + pthread_mutex_t lock; }; struct proc_entry * proc_entry_create(pid_t proc, |