diff options
Diffstat (limited to 'src/irmd')
-rw-r--r-- | src/irmd/irm_flow.h | 2 | ||||
-rw-r--r-- | src/irmd/main.c | 48 | ||||
-rw-r--r-- | src/irmd/registry.c | 2 |
3 files changed, 38 insertions, 14 deletions
diff --git a/src/irmd/irm_flow.h b/src/irmd/irm_flow.h index 507295bd..40a6bb8d 100644 --- a/src/irmd/irm_flow.h +++ b/src/irmd/irm_flow.h @@ -56,7 +56,7 @@ struct irm_flow { pthread_mutex_t state_lock; }; -struct irm_flow * irm_flow_create(); +struct irm_flow * irm_flow_create(void); void irm_flow_destroy(struct irm_flow * f); diff --git a/src/irmd/main.c b/src/irmd/main.c index 8d9d04ac..4dee4b91 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -129,7 +129,7 @@ static struct irm_flow * get_irm_flow_n(pid_t n_api) return NULL; } -static struct ipcp_entry * ipcp_entry_create() +static struct ipcp_entry * ipcp_entry_create(void) { struct ipcp_entry * e = malloc(sizeof(*e)); if (e == NULL) @@ -694,7 +694,7 @@ static int unbind_api(pid_t api, char * name) static ssize_t list_ipcps(char * name, pid_t ** apis) { struct list_head * pos = NULL; - ssize_t count = 0; + size_t count = 0; int i = 0; pthread_rwlock_rdlock(&irmd->state_lock); @@ -729,7 +729,7 @@ static ssize_t list_ipcps(char * name, pid_t ** apis) static int name_reg(char * name, char ** difs, size_t len) { - int i; + size_t i; int ret = 0; struct list_head * p = NULL; @@ -829,7 +829,7 @@ static int name_reg(char * name, char ** difs, size_t len) static int name_unreg(char * name, char ** difs, size_t len) { - int i; + size_t i; int ret = 0; struct list_head * pos = NULL; @@ -1127,6 +1127,7 @@ static struct irm_flow * flow_alloc(pid_t api, int port_id; /* FIXME: Map qos_spec to qos_cube */ + (void) qos; pthread_rwlock_rdlock(&irmd->state_lock); @@ -1162,10 +1163,18 @@ static struct irm_flow * flow_alloc(pid_t api, pthread_rwlock_wrlock(&irmd->flows_lock); port_id = f->port_id = bmp_allocate(irmd->port_ids); - f->n_1_api = ipcp; + if (!bmp_is_id_valid(irmd->port_ids, (ssize_t) port_id)) { + pthread_rwlock_unlock(&irmd->flows_lock); + pthread_rwlock_unlock(&irmd->state_lock); + LOG_ERR("Could not allocate port_id."); + irm_flow_destroy(f); + return NULL; + } + f->n_1_api = ipcp; f->n_rb = shm_rbuff_create(api, port_id); if (f->n_rb == NULL) { + bmp_release(irmd->port_ids, port_id); pthread_rwlock_unlock(&irmd->flows_lock); pthread_rwlock_unlock(&irmd->state_lock); LOG_ERR("Could not create ringbuffer for AP-I %d.", api); @@ -1175,6 +1184,7 @@ static struct irm_flow * flow_alloc(pid_t api, f->n_1_rb = shm_rbuff_create(ipcp, port_id); if (f->n_1_rb == NULL) { + bmp_release(irmd->port_ids, port_id); pthread_rwlock_unlock(&irmd->flows_lock); pthread_rwlock_unlock(&irmd->state_lock); LOG_ERR("Could not create ringbuffer for AP-I %d.", ipcp); @@ -1460,6 +1470,13 @@ static struct irm_flow * flow_req_arr(pid_t api, pthread_rwlock_wrlock(&irmd->flows_lock); f->port_id = bmp_allocate(irmd->port_ids); + if (!bmp_is_id_valid(irmd->port_ids, f->port_id)) { + pthread_rwlock_unlock(&irmd->flows_lock); + pthread_rwlock_unlock(&irmd->state_lock); + LOG_ERR("Could not create ringbuffer for AP-I %d.", f->n_api); + irm_flow_destroy(f); + return NULL; + } f->n_rb = shm_rbuff_create(f->n_api, f->port_id); if (f->n_rb == NULL) { @@ -1545,7 +1562,7 @@ static int flow_alloc_reply(int port_id, int response) return 0; } -static void irm_destroy() +static void irm_destroy(void) { struct list_head * p; struct list_head * h; @@ -1630,6 +1647,9 @@ static void irm_destroy() void irmd_sig_handler(int sig, siginfo_t * info, void * c) { + (void) info; + (void) c; + switch(sig) { case SIGINT: case SIGTERM: @@ -1649,7 +1669,7 @@ void irmd_sig_handler(int sig, siginfo_t * info, void * c) } } -void * irm_sanitize() +void * irm_sanitize(void * o) { struct timespec now; struct list_head * p = NULL; @@ -1659,6 +1679,8 @@ void * irm_sanitize() IRMD_CLEANUP_TIMER % BILLION}; int s; + (void) o; + while (true) { if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) LOG_WARN("Failed to get time."); @@ -1758,10 +1780,12 @@ void * irm_sanitize() } } -void * mainloop() +void * mainloop(void * o) { uint8_t buf[IRM_MSG_BUF_SIZE]; + (void) o; + while (true) { int cli_sockfd; irm_msg_t * msg; @@ -1967,7 +1991,7 @@ void * mainloop() return (void *) 0; } -static int irm_create() +static int irm_create(void) { struct stat st = {0}; struct timeval timeout = {(IRMD_ACCEPT_TIMEOUT / 1000), @@ -2053,7 +2077,7 @@ static int irm_create() if (kill(lockfile_owner(irmd->lf), 0) < 0) { LOG_INFO("IRMd didn't properly shut down last time."); /* FIXME: do this for each QOS_CUBE in the system */ - shm_rdrbuff_destroy(shm_rdrbuff_open(QOS_CUBE_BE)); + shm_rdrbuff_destroy(shm_rdrbuff_open()); LOG_INFO("Stale resources cleaned"); lockfile_destroy(irmd->lf); irmd->lf = lockfile_create(); @@ -2072,7 +2096,7 @@ static int irm_create() } /* FIXME: create an rdrb for each QOS_CUBE in the system */ - if ((irmd->rdrb = shm_rdrbuff_create(QOS_CUBE_BE)) == NULL) { + if ((irmd->rdrb = shm_rdrbuff_create()) == NULL) { irm_destroy(); return -1; } @@ -2084,7 +2108,7 @@ static int irm_create() return 0; } -static void usage() +static void usage(void) { LOG_ERR("Usage: irmd \n\n" " [--stdout (Print to stdout instead of logs)]\n"); diff --git a/src/irmd/registry.c b/src/irmd/registry.c index f57d833a..9442f3db 100644 --- a/src/irmd/registry.c +++ b/src/irmd/registry.c @@ -42,7 +42,7 @@ struct reg_dif { enum ipcp_type type; }; -static struct reg_entry * reg_entry_create() +static struct reg_entry * reg_entry_create(void) { struct reg_entry * e = malloc(sizeof(*e)); if (e == NULL) |