summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-27 23:22:09 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-27 23:29:13 +0200
commitf897c97de0b28cc2e48bba1bb9fc986fe4659819 (patch)
tree455165542c2bd490affb4169d83965df1119a1d0
parent7fd43a33c5964fcf0f8de2efc9dbf27f8db25fc4 (diff)
downloadouroboros-f897c97de0b28cc2e48bba1bb9fc986fe4659819.tar.gz
ouroboros-f897c97de0b28cc2e48bba1bb9fc986fe4659819.zip
irmd: Add state checks to api_entry
Prevents double destruction.
-rw-r--r--src/irmd/api_table.c10
-rw-r--r--src/irmd/api_table.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/src/irmd/api_table.c b/src/irmd/api_table.c
index 2747ed1a..519b4efe 100644
--- a/src/irmd/api_table.c
+++ b/src/irmd/api_table.c
@@ -70,6 +70,11 @@ void api_entry_destroy(struct api_entry * e)
pthread_mutex_lock(&e->state_lock);
+ if (e->state == API_DESTROY) {
+ pthread_mutex_unlock(&e->state_lock);
+ return;
+ }
+
if (e->state == API_SLEEP)
e->state = API_DESTROY;
@@ -163,6 +168,9 @@ int api_entry_sleep(struct api_entry * e)
}
}
+ if (e->state == API_DESTROY)
+ ret = -1;
+
e->state = API_INIT;
pthread_cond_broadcast(&e->state_cond);
pthread_mutex_unlock(&e->state_lock);
@@ -177,7 +185,7 @@ void api_entry_wake(struct api_entry * e, struct reg_entry * re)
pthread_mutex_lock(&e->state_lock);
- if (e->state == API_NULL) {
+ if (e->state != API_SLEEP) {
pthread_mutex_unlock(&e->state_lock);
return;
}
diff --git a/src/irmd/api_table.h b/src/irmd/api_table.h
index 0758fdb8..8741a86b 100644
--- a/src/irmd/api_table.h
+++ b/src/irmd/api_table.h
@@ -41,7 +41,7 @@ struct api_entry {
pid_t api;
char * apn; /* application process instantiated */
char * daf_name; /* DAF this AP-I belongs to */
- struct list_head names; /* names for which this api accepts flows */
+ struct list_head names; /* names for which api accepts flows */
struct reg_entry * re; /* reg_entry for which a flow arrived */