diff options
author | Dimitri Staessens <dimitri.staessens@intec.ugent.be> | 2016-03-15 15:48:28 +0100 |
---|---|---|
committer | Dimitri Staessens <dimitri.staessens@intec.ugent.be> | 2016-03-15 15:48:28 +0100 |
commit | 7ca8145790db15d7da3c2f1b260ad3421993b67c (patch) | |
tree | 168c30a3090d14c654967d0942b4718cd4a979a9 /src/irmd/main.c | |
parent | 74dc5818ac8586fcc36915874592c9f4fbb4e6f6 (diff) | |
parent | bd7a8ea8a1adbd6763aea857e72623929b7ad7a4 (diff) | |
download | ouroboros-7ca8145790db15d7da3c2f1b260ad3421993b67c.tar.gz ouroboros-7ca8145790db15d7da3c2f1b260ad3421993b67c.zip |
Merged in sandervrijders/ouroboros/be-ipcp (pull request #31)
irmd, lib: Create and destroy IPC Processes
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r-- | src/irmd/main.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 9a072382..b695519a 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -38,7 +38,7 @@ struct name_to_pid_entry { struct list_head next; - int pid; + pid_t pid; rina_name_t * name; }; @@ -46,8 +46,8 @@ struct irm { struct list_head name_to_pid; }; -static int find_pid_by_name(struct irm * instance, - rina_name_t * name) +static pid_t find_pid_by_name(struct irm * instance, + rina_name_t * name) { struct list_head * pos; @@ -68,11 +68,11 @@ static void create_ipcp(struct irm * instance, rina_name_t name, char * ipcp_type) { - int pid; + pid_t pid; struct name_to_pid_entry * tmp; pid = ipcp_create(name, ipcp_type); - if (pid == 0) { + if (pid == -1) { LOG_ERR("Failed to create IPCP"); return; } @@ -90,14 +90,17 @@ static void create_ipcp(struct irm * instance, return; } + LOG_DBG("Created IPC process with pid %d", pid); + list_add(&tmp->next, &instance->name_to_pid); } static void destroy_ipcp(struct irm * instance, rina_name_t name) { - int pid = 0; + pid_t pid = 0; struct list_head * pos; + struct list_head * n; pid = find_pid_by_name(instance, &name); if (pid == 0) { @@ -105,10 +108,12 @@ static void destroy_ipcp(struct irm * instance, return; } + LOG_DBG("Destroying ipcp with pid %d", pid); + if (ipcp_destroy(pid)) LOG_ERR("Could not destroy IPCP"); - list_for_each(pos, &instance->name_to_pid) { + list_for_each_safe(pos, n, &(instance->name_to_pid)) { struct name_to_pid_entry * tmp = list_entry(pos, struct name_to_pid_entry, next); @@ -121,7 +126,7 @@ static void bootstrap_ipcp(struct irm * instance, rina_name_t name, struct dif_config conf) { - int pid = 0; + pid_t pid = 0; pid = find_pid_by_name(instance, &name); if (pid == 0) { @@ -137,7 +142,7 @@ static void enroll_ipcp(struct irm * instance, rina_name_t name, char * dif_name) { - int pid = 0; + pid_t pid = 0; rina_name_t * member; char ** n_1_difs = NULL; ssize_t n_1_difs_size = 0; @@ -166,7 +171,7 @@ static void reg_ipcp(struct irm * instance, char ** difs, size_t difs_size) { - int pid = 0; + pid_t pid = 0; pid = find_pid_by_name(instance, &name); if (pid == 0) { @@ -183,7 +188,7 @@ static void unreg_ipcp(struct irm * instance, char ** difs, size_t difs_size) { - int pid = 0; + pid_t pid = 0; pid = find_pid_by_name(instance, &name); if (pid == 0) { |