summaryrefslogtreecommitdiff
path: root/src/irmd/main.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-08-06 12:07:37 +0000
committerSander Vrijders <[email protected]>2017-08-06 12:07:37 +0000
commit71dda25215e03e20dbe51f6071ea37b3ca3b3cdc (patch)
tree34e18d36a6cd46194d10265c517c802eeb3b784c /src/irmd/main.c
parentf85c70fdb6dbbadb903155120892e55b0eff5dda (diff)
parentb4568842c014eb6fff2305c508b20d7ae9186d4c (diff)
downloadouroboros-71dda25215e03e20dbe51f6071ea37b3ca3b3cdc.tar.gz
ouroboros-71dda25215e03e20dbe51f6071ea37b3ca3b3cdc.zip
Merged in dstaesse/ouroboros/be-irmd-timeo (pull request #542)0.6
irmd: Specify timeout per command
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r--src/irmd/main.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 96b0b729..3f83ab2c 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -222,7 +222,8 @@ static struct ipcp_entry * get_ipcp_entry_by_name(const char * name)
return NULL;
}
-static struct ipcp_entry * get_ipcp_by_dst_name(const char * name)
+static struct ipcp_entry * get_ipcp_by_dst_name(const char * name,
+ pid_t src)
{
struct list_head * p;
struct list_head * h;
@@ -233,7 +234,7 @@ static struct ipcp_entry * get_ipcp_by_dst_name(const char * name)
list_for_each_safe(p, h, &irmd.ipcps) {
struct ipcp_entry * e = list_entry(p, struct ipcp_entry, next);
- if (e->dif_name == NULL)
+ if (e->dif_name == NULL || e->api == src)
continue;
hash = malloc(IPCP_HASH_LEN(e));
@@ -1103,7 +1104,7 @@ static int flow_alloc(pid_t api,
int state;
uint8_t * hash;
- ipcp = get_ipcp_by_dst_name(dst);
+ ipcp = get_ipcp_by_dst_name(dst, api);
if (ipcp == NULL) {
log_info("Destination %s unreachable.", dst);
return -1;
@@ -1199,7 +1200,7 @@ static int flow_dealloc(pid_t api,
if (irm_flow_get_state(f) == FLOW_DEALLOC_PENDING) {
list_del(&f->next);
if ((kill(f->n_api, 0) < 0 && f->n_1_api == -1) ||
- (kill (f->n_1_api, 0) < 0 && f->n_api == -1))
+ (kill(f->n_1_api, 0) < 0 && f->n_api == -1))
irm_flow_set_state(f, FLOW_NULL);
clear_irm_flow(f);
irm_flow_destroy(f);
@@ -1638,6 +1639,8 @@ void * irm_sanitize(void * o)
pthread_rwlock_wrlock(&irmd.flows_lock);
list_for_each_safe(p, h, &irmd.irm_flows) {
+ int ipcpi;
+ int port_id;
struct irm_flow * f =
list_entry(p, struct irm_flow, next);
@@ -1645,9 +1648,13 @@ void * irm_sanitize(void * o)
&& ts_diff_ms(&f->t0, &now) > IRMD_FLOW_TIMEOUT) {
log_dbg("Pending port_id %d timed out.",
f->port_id);
- f->n_1_api = -1;
+ f->n_api = -1;
irm_flow_set_state(f, FLOW_DEALLOC_PENDING);
- ipcp_flow_dealloc(f->n_1_api, f->port_id);
+ ipcpi = f->n_1_api;
+ port_id = f->port_id;
+ pthread_rwlock_unlock(&irmd.flows_lock);
+ ipcp_flow_dealloc(ipcpi, port_id);
+ pthread_rwlock_wrlock(&irmd.flows_lock);
continue;
}
@@ -1660,7 +1667,11 @@ void * irm_sanitize(void * o)
shm_flow_set_destroy(set);
f->n_api = -1;
irm_flow_set_state(f, FLOW_DEALLOC_PENDING);
- ipcp_flow_dealloc(f->n_1_api, f->port_id);
+ ipcpi = f->n_1_api;
+ port_id = f->port_id;
+ pthread_rwlock_unlock(&irmd.flows_lock);
+ ipcp_flow_dealloc(ipcpi, port_id);
+ pthread_rwlock_wrlock(&irmd.flows_lock);
continue;
}