From d53c28a0b0aeb9f884624a13d08697a79ebc3d71 Mon Sep 17 00:00:00 2001 From: dptr1988 Date: Sun, 23 Jan 2011 14:49:49 -0800 Subject: Changed the atexit code to trip the timer thread's write signal. This fixes one of the causes of the "pthread_cond_destroy(ref) failed, 16 EBUSY" error, in which the timer thread was stuck waiting on the write_happend signal and never read the cancel request. This doesn't fix the issue of attempting to cancel threads waiting on a Linda signal. So this error message ( and seg fault ) can easily be recreated just by making a new thread, having it wait indefinitly on a Linda and then trying to cancel the thread. --- src/lanes.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lanes.c b/src/lanes.c index aef023e..0873339 100644 --- a/src/lanes.c +++ b/src/lanes.c @@ -989,6 +989,11 @@ static void selfdestruct_remove( struct s_lane *s ) { MUTEX_UNLOCK( &selfdestruct_cs ); } +// Initialized by 'init_once_LOCKED()': the deep userdata Linda object +// used for timers (each lane will get a proxy to this) +// +volatile DEEP_PRELUDE *timer_deep; // = NULL + /* * Process end; cancel any still free-running threads */ @@ -1008,6 +1013,10 @@ static void selfdestruct_atexit( void ) { } MUTEX_UNLOCK( &selfdestruct_cs ); + // Tell the timer thread to check it's cancel request + struct s_Linda *td = timer_deep->deep; + SIGNAL_ALL( &td->write_happened); + // When noticing their cancel, the lanes will remove themselves from // the selfdestruct chain. @@ -1954,11 +1963,6 @@ __declspec(dllexport) #endif luaopen_lanes( lua_State *L ) { - // Initialized by 'init_once_LOCKED()': the deep userdata Linda object - // used for timers (each lane will get a proxy to this) - // - static volatile DEEP_PRELUDE *timer_deep; // = NULL - /* * Making one-time initializations. * -- cgit v1.2.3-55-g6feb