diff options
author | dptr1988 <junk_mail@dptr1988.mooo.com> | 2011-01-23 14:49:49 -0800 |
---|---|---|
committer | dptr1988 <junk_mail@dptr1988.mooo.com> | 2011-01-23 15:21:00 -0800 |
commit | d53c28a0b0aeb9f884624a13d08697a79ebc3d71 (patch) | |
tree | 1d02631d4627aa9520e89e024e5a5a5cdfc4022b /src | |
parent | 1a038f4427bdcacb5c2a224dda33165d3eb23acd (diff) | |
download | lanes-d53c28a0b0aeb9f884624a13d08697a79ebc3d71.tar.gz lanes-d53c28a0b0aeb9f884624a13d08697a79ebc3d71.tar.bz2 lanes-d53c28a0b0aeb9f884624a13d08697a79ebc3d71.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/lanes.c | 14 |
1 files changed, 9 insertions, 5 deletions
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 ) { | |||
989 | MUTEX_UNLOCK( &selfdestruct_cs ); | 989 | MUTEX_UNLOCK( &selfdestruct_cs ); |
990 | } | 990 | } |
991 | 991 | ||
992 | // Initialized by 'init_once_LOCKED()': the deep userdata Linda object | ||
993 | // used for timers (each lane will get a proxy to this) | ||
994 | // | ||
995 | volatile DEEP_PRELUDE *timer_deep; // = NULL | ||
996 | |||
992 | /* | 997 | /* |
993 | * Process end; cancel any still free-running threads | 998 | * Process end; cancel any still free-running threads |
994 | */ | 999 | */ |
@@ -1008,6 +1013,10 @@ static void selfdestruct_atexit( void ) { | |||
1008 | } | 1013 | } |
1009 | MUTEX_UNLOCK( &selfdestruct_cs ); | 1014 | MUTEX_UNLOCK( &selfdestruct_cs ); |
1010 | 1015 | ||
1016 | // Tell the timer thread to check it's cancel request | ||
1017 | struct s_Linda *td = timer_deep->deep; | ||
1018 | SIGNAL_ALL( &td->write_happened); | ||
1019 | |||
1011 | // When noticing their cancel, the lanes will remove themselves from | 1020 | // When noticing their cancel, the lanes will remove themselves from |
1012 | // the selfdestruct chain. | 1021 | // the selfdestruct chain. |
1013 | 1022 | ||
@@ -1954,11 +1963,6 @@ __declspec(dllexport) | |||
1954 | #endif | 1963 | #endif |
1955 | luaopen_lanes( lua_State *L ) { | 1964 | luaopen_lanes( lua_State *L ) { |
1956 | 1965 | ||
1957 | // Initialized by 'init_once_LOCKED()': the deep userdata Linda object | ||
1958 | // used for timers (each lane will get a proxy to this) | ||
1959 | // | ||
1960 | static volatile DEEP_PRELUDE *timer_deep; // = NULL | ||
1961 | |||
1962 | /* | 1966 | /* |
1963 | * Making one-time initializations. | 1967 | * Making one-time initializations. |
1964 | * | 1968 | * |