summaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2012-08-10 08:28:11 +0200
committerBenoit Germain <bnt.germain@gmail.com>2012-08-10 08:28:11 +0200
commit32aa7012099d6a4b714aef27ab9dbacbdb728c1f (patch)
treee6408603a0b07324dcd0cdc189558eafad320785 /src/lanes.c
parent41b4da54f25d9870b5a0a965815be1e3c1578e80 (diff)
downloadlanes-32aa7012099d6a4b714aef27ab9dbacbdb728c1f.tar.gz
lanes-32aa7012099d6a4b714aef27ab9dbacbdb728c1f.tar.bz2
lanes-32aa7012099d6a4b714aef27ab9dbacbdb728c1f.zip
fix possible crash at application shutdown when a race condition causes linda objects to be collected after the keeper states are cleaned up.
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/lanes.c b/src/lanes.c
index b65c6fa..262a497 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -1070,7 +1070,7 @@ volatile DEEP_PRELUDE *timer_deep; // = NULL
1070/* 1070/*
1071* Process end; cancel any still free-running threads 1071* Process end; cancel any still free-running threads
1072*/ 1072*/
1073static int selfdestruct_atexit( lua_State *L) 1073static int selfdestruct_gc( lua_State *L)
1074{ 1074{
1075 (void)L; // unused 1075 (void)L; // unused
1076 if (selfdestruct_first == SELFDESTRUCT_END) return 0; // no free-running threads 1076 if (selfdestruct_first == SELFDESTRUCT_END) return 0; // no free-running threads
@@ -1214,7 +1214,6 @@ static int selfdestruct_atexit( lua_State *L)
1214 DEBUGEXEC(fprintf( stderr, "Killed %d lane(s) at process end.\n", n )); 1214 DEBUGEXEC(fprintf( stderr, "Killed %d lane(s) at process end.\n", n ));
1215#endif 1215#endif
1216 } 1216 }
1217 close_keepers();
1218 return 0; 1217 return 0;
1219} 1218}
1220 1219
@@ -2363,7 +2362,6 @@ static void init_once_LOCKED( lua_State* L, volatile DEEP_PRELUDE** timer_deep_r
2363 // Selfdestruct chain handling 2362 // Selfdestruct chain handling
2364 // 2363 //
2365 MUTEX_INIT( &selfdestruct_cs ); 2364 MUTEX_INIT( &selfdestruct_cs );
2366 //atexit( selfdestruct_atexit );
2367 2365
2368 //--- 2366 //---
2369 // Linux needs SCHED_RR to change thread priorities, and that is only 2367 // Linux needs SCHED_RR to change thread priorities, and that is only
@@ -2421,7 +2419,7 @@ static void init_once_LOCKED( lua_State* L, volatile DEEP_PRELUDE** timer_deep_r
2421 { 2419 {
2422 lua_newuserdata( L, 1); 2420 lua_newuserdata( L, 1);
2423 lua_newtable( L); 2421 lua_newtable( L);
2424 lua_pushcfunction( L, selfdestruct_atexit); 2422 lua_pushcfunction( L, selfdestruct_gc);
2425 lua_setfield( L, -2, "__gc"); 2423 lua_setfield( L, -2, "__gc");
2426 lua_pushliteral( L, "AtExit"); 2424 lua_pushliteral( L, "AtExit");
2427 lua_setfield( L, -2, "__metatable"); 2425 lua_setfield( L, -2, "__metatable");