summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/ipcp.c31
-rw-r--r--src/irmd/ipcp.h9
-rw-r--r--src/irmd/irm_flow.c12
-rw-r--r--src/irmd/irm_flow.h11
-rw-r--r--src/irmd/main.c195
-rw-r--r--src/irmd/proc_table.c7
-rw-r--r--src/irmd/prog_table.c3
-rw-r--r--src/irmd/registry.c4
-rw-r--r--src/irmd/registry.h1
9 files changed, 144 insertions, 129 deletions
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index dc8f1c6e..20aee79f 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -429,28 +429,29 @@ int ipcp_query(pid_t pid,
}
int ipcp_flow_alloc(pid_t pid,
- int port_id,
+ int flow_id,
pid_t n_pid,
const uint8_t * dst,
size_t len,
- qoscube_t cube)
+ qosspec_t qs)
{
- ipcp_msg_t msg = IPCP_MSG__INIT;
- ipcp_msg_t * recv_msg = NULL;
- int ret = -1;
+ ipcp_msg_t msg = IPCP_MSG__INIT;
+ qosspec_msg_t qs_msg;
+ ipcp_msg_t * recv_msg = NULL;
+ int ret = -1;
assert(dst);
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC;
- msg.has_port_id = true;
- msg.port_id = port_id;
+ msg.has_flow_id = true;
+ msg.flow_id = flow_id;
msg.has_pid = true;
msg.pid = n_pid;
msg.has_hash = true;
msg.hash.len = len;
msg.hash.data = (uint8_t *) dst;
- msg.has_qoscube = true;
- msg.qoscube = cube;
+ qs_msg = spec_to_msg(&qs);
+ msg.qosspec = &qs_msg;
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)
@@ -468,7 +469,7 @@ int ipcp_flow_alloc(pid_t pid,
}
int ipcp_flow_alloc_resp(pid_t pid,
- int port_id,
+ int flow_id,
pid_t n_pid,
int response)
{
@@ -477,8 +478,8 @@ int ipcp_flow_alloc_resp(pid_t pid,
int ret = -1;
msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP;
- msg.has_port_id = true;
- msg.port_id = port_id;
+ msg.has_flow_id = true;
+ msg.flow_id = flow_id;
msg.has_pid = true;
msg.pid = n_pid;
msg.has_response = true;
@@ -500,15 +501,15 @@ int ipcp_flow_alloc_resp(pid_t pid,
}
int ipcp_flow_dealloc(pid_t pid,
- int port_id)
+ int flow_id)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
int ret = -1;
msg.code = IPCP_MSG_CODE__IPCP_FLOW_DEALLOC;
- msg.has_port_id = true;
- msg.port_id = port_id;
+ msg.has_flow_id = true;
+ msg.flow_id = flow_id;
recv_msg = send_recv_ipcp_msg(pid, &msg);
if (recv_msg == NULL)
diff --git a/src/irmd/ipcp.h b/src/irmd/ipcp.h
index 8ff062b2..8d9686c2 100644
--- a/src/irmd/ipcp.h
+++ b/src/irmd/ipcp.h
@@ -22,7 +22,6 @@
#include <ouroboros/ipcp.h>
#include <ouroboros/sockets.h>
-#include <ouroboros/qoscube.h>
#include <sys/types.h>
@@ -63,18 +62,18 @@ int ipcp_query(pid_t pid,
size_t len);
int ipcp_flow_alloc(pid_t pid,
- int port_id,
+ int flow_id,
pid_t n_pid,
const uint8_t * dst,
size_t len,
- qoscube_t qos);
+ qosspec_t qs);
int ipcp_flow_alloc_resp(pid_t pid,
- int port_id,
+ int flow_id,
pid_t n_pid,
int response);
int ipcp_flow_dealloc(pid_t pid,
- int port_id);
+ int flow_id);
#endif /* OUROBOROS_IRMD_IPCP_H */
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index dfbe5e95..a0889f09 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -38,8 +38,8 @@
struct irm_flow * irm_flow_create(pid_t n_pid,
pid_t n_1_pid,
- int port_id,
- qoscube_t qc)
+ int flow_id,
+ qosspec_t qs)
{
pthread_condattr_t cattr;
struct irm_flow * f = malloc(sizeof(*f));
@@ -60,16 +60,16 @@ struct irm_flow * irm_flow_create(pid_t n_pid,
f->n_pid = n_pid;
f->n_1_pid = n_1_pid;
- f->port_id = port_id;
- f->qc = qc;
+ f->flow_id = flow_id;
+ f->qs = qs;
- f->n_rb = shm_rbuff_create(n_pid, port_id);
+ f->n_rb = shm_rbuff_create(n_pid, flow_id);
if (f->n_rb == NULL) {
log_err("Could not create ringbuffer for process %d.", n_pid);
goto fail_n_rbuff;
}
- f->n_1_rb = shm_rbuff_create(n_1_pid, port_id);
+ f->n_1_rb = shm_rbuff_create(n_1_pid, flow_id);
if (f->n_1_rb == NULL) {
log_err("Could not create ringbuffer for process %d.", n_1_pid);
goto fail_n_1_rbuff;
diff --git a/src/irmd/irm_flow.h b/src/irmd/irm_flow.h
index d53984e8..26263107 100644
--- a/src/irmd/irm_flow.h
+++ b/src/irmd/irm_flow.h
@@ -24,8 +24,8 @@
#define OUROBOROS_IRMD_IRM_FLOW_H
#include <ouroboros/list.h>
+#include <ouroboros/qos.h>
#include <ouroboros/shm_rbuff.h>
-#include <ouroboros/qoscube.h>
#include <sys/types.h>
#include <pthread.h>
@@ -42,12 +42,13 @@ enum flow_state {
struct irm_flow {
struct list_head next;
- int port_id;
- qoscube_t qc;
+ int flow_id;
pid_t n_pid;
pid_t n_1_pid;
+ qosspec_t qs;
+
struct shm_rbuff * n_rb;
struct shm_rbuff * n_1_rb;
@@ -60,8 +61,8 @@ struct irm_flow {
struct irm_flow * irm_flow_create(pid_t n_pid,
pid_t n_1_pid,
- int port_id,
- qoscube_t qc);
+ int flow_id,
+ qosspec_t qs);
void irm_flow_destroy(struct irm_flow * f);
diff --git a/src/irmd/main.c b/src/irmd/main.c
index aeb43f0d..78fcf7b5 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -20,8 +20,11 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#define _POSIX_C_SOURCE 200812L
-#define __XSI_VISIBLE 500
+#if defined(__linux__) || defined(__CYGWIN__)
+#define _DEFAULT_SOURCE
+#else
+#define _POSIX_C_SOURCE 200809L
+#endif
#include "config.h"
@@ -115,12 +118,12 @@ struct {
struct list_head spawned_pids; /* child processes */
pthread_rwlock_t reg_lock; /* lock for registration info */
- struct bmp * port_ids; /* port_ids for flows */
+ struct bmp * flow_ids; /* flow_ids for flows */
struct list_head irm_flows; /* flow information */
pthread_rwlock_t flows_lock; /* lock for flows */
struct lockfile * lf; /* single irmd per system */
- struct shm_rdrbuff * rdrb; /* rdrbuff for SDUs */
+ struct shm_rdrbuff * rdrb; /* rdrbuff for packets */
int sockfd; /* UNIX socket */
@@ -171,13 +174,13 @@ static void clear_irm_flow(struct irm_flow * f) {
shm_rdrbuff_remove(irmd.rdrb, idx);
}
-static struct irm_flow * get_irm_flow(int port_id)
+static struct irm_flow * get_irm_flow(int flow_id)
{
struct list_head * pos = NULL;
list_for_each(pos, &irmd.irm_flows) {
struct irm_flow * e = list_entry(pos, struct irm_flow, next);
- if (e->port_id == port_id)
+ if (e->flow_id == flow_id)
return e;
}
@@ -346,8 +349,10 @@ static struct ipcp_entry * get_ipcp_by_dst_name(const char * name,
len = IPCP_HASH_LEN(e);
hash = malloc(len);
- if (hash == NULL)
+ if (hash == NULL) {
+ pthread_rwlock_unlock(&irmd.reg_lock);
return NULL;
+ }
str_hash(e->dir_hash_algo, hash, name);
@@ -825,13 +830,13 @@ static int unbind_program(char * prog,
if (name == NULL)
prog_table_del(&irmd.prog_table, prog);
else {
- struct prog_entry * e = prog_table_get(&irmd.prog_table, prog);
- prog_entry_del_name(e, name);
- }
+ struct prog_entry * en = prog_table_get(&irmd.prog_table, prog);
+ prog_entry_del_name(en, name);
- e = registry_get_entry(&irmd.registry, name);
- if (e != NULL)
- reg_entry_del_prog(e, prog);
+ e = registry_get_entry(&irmd.registry, name);
+ if (e != NULL)
+ reg_entry_del_prog(e, prog);
+ }
pthread_rwlock_unlock(&irmd.reg_lock);
@@ -853,13 +858,14 @@ static int unbind_process(pid_t pid,
if (name == NULL)
proc_table_del(&irmd.proc_table, pid);
else {
- struct proc_entry * e = proc_table_get(&irmd.proc_table, pid);
- proc_entry_del_name(e, name);
- }
+ struct proc_entry * en = proc_table_get(&irmd.proc_table, pid);
+ if (en != NULL)
+ proc_entry_del_name(en, name);
- e = registry_get_entry(&irmd.registry, name);
- if (e != NULL)
- reg_entry_del_pid(e, pid);
+ e = registry_get_entry(&irmd.registry, name);
+ if (e != NULL)
+ reg_entry_del_pid(e, pid);
+ }
pthread_rwlock_unlock(&irmd.reg_lock);
@@ -919,6 +925,7 @@ static ssize_t list_ipcps(ipcp_info_msg_t *** ipcps,
return 0;
fail:
+ pthread_rwlock_unlock(&irmd.reg_lock);
while (i >= 0) {
free((*ipcps)[i]->layer);
free((*ipcps)[i]->name);
@@ -1145,7 +1152,7 @@ static int flow_accept(pid_t pid,
pid_t pid_n1;
pid_t pid_n;
- int port_id;
+ int flow_id;
int ret;
pthread_rwlock_wrlock(&irmd.reg_lock);
@@ -1177,10 +1184,8 @@ static int flow_accept(pid_t pid,
if (ret == -1)
return -EPIPE;
- if (irmd_get_state() != IRMD_RUNNING) {
- reg_entry_set_state(re, REG_NAME_NULL);
+ if (irmd_get_state() != IRMD_RUNNING)
return -EIRMD;
- }
pthread_rwlock_rdlock(&irmd.flows_lock);
@@ -1193,7 +1198,7 @@ static int flow_accept(pid_t pid,
pid_n = f->n_pid;
pid_n1 = f->n_1_pid;
- port_id = f->port_id;
+ flow_id = f->flow_id;
pthread_rwlock_unlock(&irmd.flows_lock);
pthread_rwlock_rdlock(&irmd.reg_lock);
@@ -1203,9 +1208,9 @@ static int flow_accept(pid_t pid,
pthread_rwlock_unlock(&irmd.reg_lock);
pthread_rwlock_wrlock(&irmd.flows_lock);
list_del(&f->next);
- bmp_release(irmd.port_ids, f->port_id);
+ bmp_release(irmd.flow_ids, f->flow_id);
pthread_rwlock_unlock(&irmd.flows_lock);
- ipcp_flow_alloc_resp(pid_n1, port_id, pid_n, -1);
+ ipcp_flow_alloc_resp(pid_n1, flow_id, pid_n, -1);
clear_irm_flow(f);
irm_flow_set_state(f, FLOW_NULL);
irm_flow_destroy(f);
@@ -1223,9 +1228,9 @@ static int flow_accept(pid_t pid,
pthread_rwlock_unlock(&irmd.reg_lock);
pthread_rwlock_wrlock(&irmd.flows_lock);
list_del(&f->next);
- bmp_release(irmd.port_ids, f->port_id);
+ bmp_release(irmd.flow_ids, f->flow_id);
pthread_rwlock_unlock(&irmd.flows_lock);
- ipcp_flow_alloc_resp(pid_n1, port_id, pid_n, -1);
+ ipcp_flow_alloc_resp(pid_n1, flow_id, pid_n, -1);
clear_irm_flow(f);
irm_flow_set_state(f, FLOW_NULL);
irm_flow_destroy(f);
@@ -1237,7 +1242,7 @@ static int flow_accept(pid_t pid,
pthread_rwlock_unlock(&irmd.reg_lock);
- if (ipcp_flow_alloc_resp(pid_n1, port_id, pid_n, 0)) {
+ if (ipcp_flow_alloc_resp(pid_n1, flow_id, pid_n, 0)) {
pthread_rwlock_wrlock(&irmd.flows_lock);
list_del(&f->next);
pthread_rwlock_unlock(&irmd.flows_lock);
@@ -1250,7 +1255,7 @@ static int flow_accept(pid_t pid,
irm_flow_set_state(f, FLOW_ALLOCATED);
- log_info("Flow on port_id %d allocated.", f->port_id);
+ log_info("Flow on flow_id %d allocated.", f->flow_id);
*fl = f;
@@ -1259,13 +1264,13 @@ static int flow_accept(pid_t pid,
static int flow_alloc(pid_t pid,
const char * dst,
- qoscube_t cube,
+ qosspec_t qs,
struct timespec * timeo,
struct irm_flow ** e)
{
struct irm_flow * f;
struct ipcp_entry * ipcp;
- int port_id;
+ int flow_id;
int state;
uint8_t * hash;
@@ -1276,18 +1281,18 @@ static int flow_alloc(pid_t pid,
}
pthread_rwlock_wrlock(&irmd.flows_lock);
- port_id = bmp_allocate(irmd.port_ids);
- if (!bmp_is_id_valid(irmd.port_ids, port_id)) {
+ flow_id = bmp_allocate(irmd.flow_ids);
+ if (!bmp_is_id_valid(irmd.flow_ids, flow_id)) {
pthread_rwlock_unlock(&irmd.flows_lock);
- log_err("Could not allocate port_id.");
+ log_err("Could not allocate flow_id.");
return -EBADF;
}
- f = irm_flow_create(pid, ipcp->pid, port_id, cube);
+ f = irm_flow_create(pid, ipcp->pid, flow_id, qs);
if (f == NULL) {
- bmp_release(irmd.port_ids, port_id);
+ bmp_release(irmd.flow_ids, flow_id);
pthread_rwlock_unlock(&irmd.flows_lock);
- log_err("Could not allocate port_id.");
+ log_err("Could not allocate flow_id.");
return -ENOMEM;
}
@@ -1304,8 +1309,8 @@ static int flow_alloc(pid_t pid,
str_hash(ipcp->dir_hash_algo, hash, dst);
- if (ipcp_flow_alloc(ipcp->pid, port_id, pid, hash,
- IPCP_HASH_LEN(ipcp), cube)) {
+ if (ipcp_flow_alloc(ipcp->pid, flow_id, pid, hash,
+ IPCP_HASH_LEN(ipcp), qs)) {
/* sanitizer cleans this */
log_info("Flow_allocation failed.");
free(hash);
@@ -1329,13 +1334,13 @@ static int flow_alloc(pid_t pid,
*e = f;
- log_info("Flow on port_id %d allocated.", port_id);
+ log_info("Flow on flow_id %d allocated.", flow_id);
return 0;
}
static int flow_dealloc(pid_t pid,
- int port_id)
+ int flow_id)
{
pid_t n_1_pid = -1;
int ret = 0;
@@ -1344,10 +1349,10 @@ static int flow_dealloc(pid_t pid,
pthread_rwlock_wrlock(&irmd.flows_lock);
- f = get_irm_flow(port_id);
+ f = get_irm_flow(flow_id);
if (f == NULL) {
pthread_rwlock_unlock(&irmd.flows_lock);
- log_dbg("Deallocate unknown port %d by %d.", port_id, pid);
+ log_dbg("Deallocate unknown port %d by %d.", flow_id, pid);
return 0;
}
@@ -1369,19 +1374,19 @@ static int flow_dealloc(pid_t pid,
irm_flow_set_state(f, FLOW_NULL);
clear_irm_flow(f);
irm_flow_destroy(f);
- bmp_release(irmd.port_ids, port_id);
- log_info("Completed deallocation of port_id %d by process %d.",
- port_id, pid);
+ bmp_release(irmd.flow_ids, flow_id);
+ log_info("Completed deallocation of flow_id %d by process %d.",
+ flow_id, pid);
} else {
irm_flow_set_state(f, FLOW_DEALLOC_PENDING);
- log_dbg("Partial deallocation of port_id %d by process %d.",
- port_id, pid);
+ log_dbg("Partial deallocation of flow_id %d by process %d.",
+ flow_id, pid);
}
pthread_rwlock_unlock(&irmd.flows_lock);
if (n_1_pid != -1)
- ret = ipcp_flow_dealloc(n_1_pid, port_id);
+ ret = ipcp_flow_dealloc(n_1_pid, flow_id);
return ret;
}
@@ -1413,7 +1418,7 @@ static pid_t auto_execute(char ** argv)
static struct irm_flow * flow_req_arr(pid_t pid,
const uint8_t * hash,
- qoscube_t cube)
+ qosspec_t qs)
{
struct reg_entry * re = NULL;
struct prog_entry * a = NULL;
@@ -1423,7 +1428,7 @@ static struct irm_flow * flow_req_arr(pid_t pid,
struct pid_el * c_pid;
struct ipcp_entry * ipcp;
pid_t h_pid = -1;
- int port_id = -1;
+ int flow_id = -1;
struct timespec wt = {IRMD_REQ_ARR_TIMEOUT / 1000,
(IRMD_REQ_ARR_TIMEOUT % 1000) * MILLION};
@@ -1510,17 +1515,17 @@ static struct irm_flow * flow_req_arr(pid_t pid,
pthread_rwlock_unlock(&irmd.reg_lock);
pthread_rwlock_wrlock(&irmd.flows_lock);
- port_id = bmp_allocate(irmd.port_ids);
- if (!bmp_is_id_valid(irmd.port_ids, port_id)) {
+ flow_id = bmp_allocate(irmd.flow_ids);
+ if (!bmp_is_id_valid(irmd.flow_ids, flow_id)) {
pthread_rwlock_unlock(&irmd.flows_lock);
return NULL;
}
- f = irm_flow_create(h_pid, pid, port_id, cube);
+ f = irm_flow_create(h_pid, pid, flow_id, qs);
if (f == NULL) {
- bmp_release(irmd.port_ids, port_id);
+ bmp_release(irmd.flow_ids, flow_id);
pthread_rwlock_unlock(&irmd.flows_lock);
- log_err("Could not allocate port_id.");
+ log_err("Could not allocate flow_id.");
return NULL;
}
@@ -1536,7 +1541,7 @@ static struct irm_flow * flow_req_arr(pid_t pid,
pthread_rwlock_unlock(&irmd.reg_lock);
pthread_rwlock_wrlock(&irmd.flows_lock);
clear_irm_flow(f);
- bmp_release(irmd.port_ids, f->port_id);
+ bmp_release(irmd.flow_ids, f->flow_id);
list_del(&f->next);
pthread_rwlock_unlock(&irmd.flows_lock);
log_err("Could not get process table entry for %d.", h_pid);
@@ -1553,14 +1558,14 @@ static struct irm_flow * flow_req_arr(pid_t pid,
return f;
}
-static int flow_alloc_reply(int port_id,
+static int flow_alloc_reply(int flow_id,
int response)
{
struct irm_flow * f;
pthread_rwlock_rdlock(&irmd.flows_lock);
- f = get_irm_flow(port_id);
+ f = get_irm_flow(flow_id);
if (f == NULL) {
pthread_rwlock_unlock(&irmd.flows_lock);
return -1;
@@ -1626,8 +1631,8 @@ static void irm_fini(void)
pthread_rwlock_wrlock(&irmd.flows_lock);
- if (irmd.port_ids != NULL)
- bmp_destroy(irmd.port_ids);
+ if (irmd.flow_ids != NULL)
+ bmp_destroy(irmd.flow_ids);
list_for_each_safe(p, h, &irmd.irm_flows) {
struct irm_flow * f = list_entry(p, struct irm_flow, next);
@@ -1754,14 +1759,14 @@ void * irm_sanitize(void * o)
list_for_each_safe(p, h, &irmd.irm_flows) {
int ipcpi;
- int port_id;
+ int flow_id;
struct irm_flow * f =
list_entry(p, struct irm_flow, next);
if (irm_flow_get_state(f) == FLOW_ALLOC_PENDING
&& ts_diff_ms(&f->t0, &now) > IRMD_FLOW_TIMEOUT) {
- log_dbg("Pending port_id %d timed out.",
- f->port_id);
+ log_dbg("Pending flow_id %d timed out.",
+ f->flow_id);
f->n_pid = -1;
irm_flow_set_state(f, FLOW_DEALLOC_PENDING);
continue;
@@ -1771,16 +1776,16 @@ void * irm_sanitize(void * o)
struct shm_flow_set * set;
log_dbg("Process %d gone, deallocating "
"flow %d.",
- f->n_pid, f->port_id);
+ f->n_pid, f->flow_id);
set = shm_flow_set_open(f->n_pid);
if (set != NULL)
shm_flow_set_destroy(set);
f->n_pid = -1;
irm_flow_set_state(f, FLOW_DEALLOC_PENDING);
ipcpi = f->n_1_pid;
- port_id = f->port_id;
+ flow_id = f->flow_id;
pthread_rwlock_unlock(&irmd.flows_lock);
- ipcp_flow_dealloc(ipcpi, port_id);
+ ipcp_flow_dealloc(ipcpi, flow_id);
pthread_rwlock_wrlock(&irmd.flows_lock);
continue;
}
@@ -1788,7 +1793,7 @@ void * irm_sanitize(void * o)
if (kill(f->n_1_pid, 0) < 0) {
struct shm_flow_set * set;
log_err("IPCP %d gone, flow %d removed.",
- f->n_1_pid, f->port_id);
+ f->n_1_pid, f->flow_id);
set = shm_flow_set_open(f->n_pid);
if (set != NULL)
shm_flow_set_destroy(set);
@@ -1988,41 +1993,43 @@ static void * mainloop(void * o)
case IRM_MSG_CODE__IRM_FLOW_ACCEPT:
result = flow_accept(msg->pid, timeo, &e);
if (result == 0) {
- ret_msg->has_port_id = true;
- ret_msg->port_id = e->port_id;
+ qosspec_msg_t qs_msg;
+ ret_msg->has_flow_id = true;
+ ret_msg->flow_id = e->flow_id;
ret_msg->has_pid = true;
ret_msg->pid = e->n_1_pid;
- ret_msg->has_qoscube = true;
- ret_msg->qoscube = e->qc;
+ qs_msg = spec_to_msg(&e->qs);
+ ret_msg->qosspec = &qs_msg;
}
break;
case IRM_MSG_CODE__IRM_FLOW_ALLOC:
result = flow_alloc(msg->pid, msg->dst,
- msg->qoscube, timeo, &e);
+ msg_to_spec(msg->qosspec),
+ timeo, &e);
if (result == 0) {
- ret_msg->has_port_id = true;
- ret_msg->port_id = e->port_id;
+ ret_msg->has_flow_id = true;
+ ret_msg->flow_id = e->flow_id;
ret_msg->has_pid = true;
ret_msg->pid = e->n_1_pid;
}
break;
case IRM_MSG_CODE__IRM_FLOW_DEALLOC:
- result = flow_dealloc(msg->pid, msg->port_id);
+ result = flow_dealloc(msg->pid, msg->flow_id);
break;
case IRM_MSG_CODE__IPCP_FLOW_REQ_ARR:
e = flow_req_arr(msg->pid,
msg->hash.data,
- msg->qoscube);
+ msg_to_spec(msg->qosspec));
result = (e == NULL ? -1 : 0);
if (result == 0) {
- ret_msg->has_port_id = true;
- ret_msg->port_id = e->port_id;
+ ret_msg->has_flow_id = true;
+ ret_msg->flow_id = e->flow_id;
ret_msg->has_pid = true;
ret_msg->pid = e->n_pid;
}
break;
case IRM_MSG_CODE__IPCP_FLOW_ALLOC_REPLY:
- result = flow_alloc_reply(msg->port_id, msg->response);
+ result = flow_alloc_reply(msg->flow_id, msg->response);
break;
default:
log_err("Don't know that message code.");
@@ -2056,6 +2063,8 @@ static void * mainloop(void * o)
irm_msg__pack(ret_msg, buffer.data);
+ /* Can't free the qosspec. */
+ ret_msg->qosspec = NULL;
irm_msg__free_unpacked(ret_msg, NULL);
pthread_cleanup_push(close_ptr, &sfd);
@@ -2134,10 +2143,10 @@ static int irm_init(void)
list_head_init(&irmd.irm_flows);
list_head_init(&irmd.cmds);
- irmd.port_ids = bmp_create(SYS_MAX_FLOWS, 0);
- if (irmd.port_ids == NULL) {
- log_err("Failed to create port_ids bitmap.");
- goto fail_port_ids;
+ irmd.flow_ids = bmp_create(SYS_MAX_FLOWS, 0);
+ if (irmd.flow_ids == NULL) {
+ log_err("Failed to create flow_ids bitmap.");
+ goto fail_flow_ids;
}
if ((irmd.lf = lockfile_create()) == NULL) {
@@ -2160,6 +2169,11 @@ static int irm_init(void)
}
}
+ if (irmd.lf == NULL) {
+ log_err("Failed to create lockfile.");
+ goto fail_lockfile;
+ }
+
if (stat(SOCK_PATH, &st) == -1) {
if (mkdir(SOCK_PATH, 0777)) {
log_err("Failed to create sockets directory.");
@@ -2184,11 +2198,6 @@ static int irm_init(void)
goto fail_sock_opt;
}
- if (irmd.lf == NULL) {
- log_err("Failed to create lockfile.");
- goto fail_sock_opt;
- }
-
if ((irmd.rdrb = shm_rdrbuff_create()) == NULL) {
log_err("Failed to create rdrbuff.");
goto fail_rdrbuff;
@@ -2207,7 +2216,7 @@ static int irm_init(void)
gcry_control(GCRYCTL_INITIALIZATION_FINISHED);
#endif
- irmd.state = IRMD_RUNNING;
+ irmd_set_state(IRMD_RUNNING);
log_info("Ouroboros IPC Resource Manager daemon started...");
@@ -2226,8 +2235,8 @@ static int irm_init(void)
fail_stat:
lockfile_destroy(irmd.lf);
fail_lockfile:
- bmp_destroy(irmd.port_ids);
- fail_port_ids:
+ bmp_destroy(irmd.flow_ids);
+ fail_flow_ids:
pthread_cond_destroy(&irmd.cmd_cond);
fail_cmd_cond:
pthread_mutex_destroy(&irmd.cmd_lock);
diff --git a/src/irmd/proc_table.c b/src/irmd/proc_table.c
index e8d08447..6f9d8e20 100644
--- a/src/irmd/proc_table.c
+++ b/src/irmd/proc_table.c
@@ -20,7 +20,11 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#if defined(__linux__) || defined(__CYGWIN__)
+#define _DEFAULT_SOURCE
+#else
#define _POSIX_C_SOURCE 200112L
+#endif
#include "config.h"
@@ -168,8 +172,7 @@ void proc_entry_del_name(struct proc_entry * e,
struct str_el * s = list_entry(p, struct str_el, next);
if (!strcmp(name, s->str)) {
list_del(&s->next);
- if (s->str != NULL)
- free(s->str);
+ free(s->str);
free(s);
}
}
diff --git a/src/irmd/prog_table.c b/src/irmd/prog_table.c
index bd69e156..9aa9be9d 100644
--- a/src/irmd/prog_table.c
+++ b/src/irmd/prog_table.c
@@ -81,8 +81,7 @@ void prog_entry_destroy(struct prog_entry * e)
list_for_each_safe(p, h, &e->names) {
struct str_el * s = list_entry(p, struct str_el, next);
list_del(&s->next);
- if (s->str != NULL)
- free(s->str);
+ free(s->str);
free(s);
}
diff --git a/src/irmd/registry.c b/src/irmd/registry.c
index 145a7452..6c86da24 100644
--- a/src/irmd/registry.c
+++ b/src/irmd/registry.c
@@ -20,7 +20,11 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#if defined(__linux__) || defined(__CYGWIN__)
+#define _DEFAULT_SOURCE
+#else
#define _POSIX_C_SOURCE 200809L
+#endif
#include "config.h"
diff --git a/src/irmd/registry.h b/src/irmd/registry.h
index 62d90c39..c9ea8cce 100644
--- a/src/irmd/registry.h
+++ b/src/irmd/registry.h
@@ -26,7 +26,6 @@
#include <ouroboros/hash.h>
#include <ouroboros/ipcp.h>
#include <ouroboros/list.h>
-#include <ouroboros/qoscube.h>
#include "proc_table.h"
#include "prog_table.h"