Reviewed-by: Steven Dake <sdake@xxxxxxxxxx> On 03/21/2012 09:23 AM, Jan Friesse wrote: > corosync_timer_init used to lock timer lock and unlock was made in > prioritized_timer_thread. Even this behavior works on Linux, NetBSD is > more strict. Mutex can be unlocked only by thread which locked it. > > Solution is to use condition and synchronize start of timer thread and > main thread. > > Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> > --- > exec/timer.c | 10 ++++++++++ > 1 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/exec/timer.c b/exec/timer.c > index 02ca51b..e894480 100644 > --- a/exec/timer.c > +++ b/exec/timer.c > @@ -83,6 +83,8 @@ > > static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER; > > +static pthread_cond_t timer_mutex_cond = PTHREAD_COND_INITIALIZER; > + > static pthread_t expiry_thread; > > static pthread_attr_t thread_attr; > @@ -116,6 +118,8 @@ static void *prioritized_timer_thread (void *data) > } > #endif > > + pthread_mutex_lock (&timer_mutex); > + pthread_cond_signal (&timer_mutex_cond); > pthread_mutex_unlock (&timer_mutex); > for (;;) { > timer_serialize_lock_fn (); > @@ -170,6 +174,12 @@ int corosync_timer_init ( > res = pthread_create (&expiry_thread, &thread_attr, > prioritized_timer_thread, NULL); > > + /* > + * Wait for thread to really exec > + */ > + pthread_cond_wait (&timer_mutex_cond, &timer_mutex); > + pthread_mutex_unlock (&timer_mutex); > + > return (res); > } > _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss