Bladeren bron

Resolve a deadlock between the timer and serialize locks.

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 <russell@russellbryant.net>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Russell Bryant 14 jaren geleden
bovenliggende
commit
a78360eb73
1 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 2 2
      exec/timer.c

+ 2 - 2
exec/timer.c

@@ -129,13 +129,13 @@ static void *prioritized_timer_thread (void *data)
 		if (fds < 0) {
 		if (fds < 0) {
 			return NULL;
 			return NULL;
 		}
 		}
-		pthread_mutex_lock (&timer_mutex);
 		timer_serialize_lock_fn ();
 		timer_serialize_lock_fn ();
+		pthread_mutex_lock (&timer_mutex);
 
 
 		timerlist_expire (&timers_timerlist);
 		timerlist_expire (&timers_timerlist);
 
 
-		timer_serialize_unlock_fn ();
 		pthread_mutex_unlock (&timer_mutex);
 		pthread_mutex_unlock (&timer_mutex);
+		timer_serialize_unlock_fn ();
 	}
 	}
 }
 }