From a69bdb85b2fb8f096f40ab038a45e0bc134e51ee Mon Sep 17 00:00:00 2001
From: dimitri staessens <dimitri.staessens@intec.ugent.be>
Date: Thu, 16 Feb 2017 14:27:07 +0100
Subject: irmd: Fix bad lock

---
 src/irmd/main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'src/irmd')

diff --git a/src/irmd/main.c b/src/irmd/main.c
index aa4614c1..7f20faf4 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1393,11 +1393,11 @@ static struct irm_flow * flow_req_arr(pid_t     api,
                 pthread_rwlock_unlock(&irmd->reg_lock);
                 pthread_rwlock_unlock(&irmd->state_lock);
 
-                if (reg_entry_leave_state(re, REG_NAME_AUTO_EXEC, NULL)) {
-                        pthread_rwlock_unlock(&irmd->reg_lock);
-                        pthread_rwlock_unlock(&irmd->state_lock);
+                if (reg_entry_leave_state(re, REG_NAME_AUTO_EXEC, NULL))
                         return NULL;
-                }
+
+                pthread_rwlock_rdlock(&irmd->state_lock);
+                pthread_rwlock_wrlock(&irmd->reg_lock);
 
         case REG_NAME_FLOW_ACCEPT:
                 h_api = reg_entry_get_api(re);
-- 
cgit v1.2.3