summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-08-04 12:30:33 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-04 12:30:33 +0200
commitf85c70fdb6dbbadb903155120892e55b0eff5dda (patch)
treecf80113aee8408b68f845ed7467cce3a8e5bb657
parente77db148ce7adbaefb2ec7fb66a1fe0a36cff72f (diff)
parent7729199645eb2c14d7b8a5329eb441f14fe7729f (diff)
downloadouroboros-f85c70fdb6dbbadb903155120892e55b0eff5dda.tar.gz
ouroboros-f85c70fdb6dbbadb903155120892e55b0eff5dda.zip
Merge branch 'testing' into be
-rw-r--r--src/ipcpd/shim-eth-llc/main.c2
-rw-r--r--src/irmd/main.c24
2 files changed, 17 insertions, 9 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 4899cd83..dcbbc047 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -1037,7 +1037,7 @@ static int eth_llc_ipcp_flow_alloc_resp(int fd,
pthread_mutex_lock(&ipcpi.alloc_lock);
- while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL){
+ while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) {
ts_add(&abstime, &ts, &abstime);
pthread_cond_timedwait(&ipcpi.alloc_cond,
&ipcpi.alloc_lock,
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 8b22bdef..96b0b729 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -224,10 +224,14 @@ static struct ipcp_entry * get_ipcp_entry_by_name(const char * name)
static struct ipcp_entry * get_ipcp_by_dst_name(const char * name)
{
- struct list_head * p = NULL;
- uint8_t * hash;
+ struct list_head * p;
+ struct list_head * h;
+ uint8_t * hash;
+ pid_t api;
- list_for_each(p, &irmd.ipcps) {
+ pthread_rwlock_rdlock(&irmd.reg_lock);
+
+ list_for_each_safe(p, h, &irmd.ipcps) {
struct ipcp_entry * e = list_entry(p, struct ipcp_entry, next);
if (e->dif_name == NULL)
continue;
@@ -238,14 +242,22 @@ static struct ipcp_entry * get_ipcp_by_dst_name(const char * name)
str_hash(e->dir_hash_algo, hash, name);
- if (ipcp_query(e->api, hash, IPCP_HASH_LEN(e)) == 0) {
+ api = e->api;
+
+ pthread_rwlock_unlock(&irmd.reg_lock);
+
+ if (ipcp_query(api, hash, IPCP_HASH_LEN(e)) == 0) {
free(hash);
return e;
}
free(hash);
+
+ pthread_rwlock_rdlock(&irmd.reg_lock);
}
+ pthread_rwlock_unlock(&irmd.reg_lock);
+
return NULL;
}
@@ -1091,16 +1103,12 @@ static int flow_alloc(pid_t api,
int state;
uint8_t * hash;
- pthread_rwlock_rdlock(&irmd.reg_lock);
-
ipcp = get_ipcp_by_dst_name(dst);
if (ipcp == NULL) {
- pthread_rwlock_unlock(&irmd.reg_lock);
log_info("Destination %s unreachable.", dst);
return -1;
}
- 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)) {