This patch resolves a deadlock between the serialize lock (in
exec/main.c) and the timer lock (in exec/timer.c).  I observed this
deadlock happening fairly quickly on a cluster using the EVT service
from OpenAIS.  (OpenAIS 1.1.4, Corosync 1.4.1)

In prioritized_timer_thread(), it was grabbing:
    1) timer lock
    2) serialize lock

In another thread, you have:
    1) grab the serialize lock in deliver_fn() of exec/main.c
    2) grab the timer lock in corosync_timer_add_duration().

The patch just swaps the locking order in the timer thread.

Signed-off-by: Russell Bryant <[email protected]>
---
 exec/timer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec/timer.c b/exec/timer.c
index 69f9a95..02ca51b 100644
--- a/exec/timer.c
+++ b/exec/timer.c
@@ -131,13 +131,13 @@ static void *prioritized_timer_thread (void *data)
                if (fds < 0) {
                        return NULL;
                }
-               pthread_mutex_lock (&timer_mutex);
                timer_serialize_lock_fn ();
+               pthread_mutex_lock (&timer_mutex);
 
                timerlist_expire (&timers_timerlist);
 
-               timer_serialize_unlock_fn ();
                pthread_mutex_unlock (&timer_mutex);
+               timer_serialize_unlock_fn ();
        }
 }
 
-- 
1.7.6

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to