diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2012-11-21 21:06:19 +0100 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2012-11-21 21:06:19 +0100 |
commit | f154e1f1b6cea07163f364986fb11ccfcb87c3ad (patch) | |
tree | 530495592fb8cf6300f5270626ced31a43c6313d | |
parent | 8c73ca05a8a6583844f7da90f3d8d1b2663a86a5 (diff) | |
download | lanes-f154e1f1b6cea07163f364986fb11ccfcb87c3ad.tar.gz lanes-f154e1f1b6cea07163f364986fb11ccfcb87c3ad.tar.bz2 lanes-f154e1f1b6cea07163f364986fb11ccfcb87c3ad.zip |
fix application shutdown crash by not registering anything with atexit()v3.4.0
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | src/keeper.c | 11 | ||||
-rw-r--r-- | src/keeper.h | 9 | ||||
-rw-r--r-- | src/lanes.c | 3 |
4 files changed, 23 insertions, 4 deletions
@@ -1,5 +1,9 @@ | |||
1 | CHANGES: | 1 | CHANGES: |
2 | 2 | ||
3 | CHANGE 49: BGe 21-Nov-2012 | ||
4 | * fix application shutdown crash by not registering anything with atexit() | ||
5 | * rockspec for version v3.4.0 | ||
6 | |||
3 | CHANGE 48: BGe 25-Sep-2012 | 7 | CHANGE 48: BGe 25-Sep-2012 |
4 | * version 3.4.0 | 8 | * version 3.4.0 |
5 | * new method linda:dump() that outputs the full contents of a linda as a table, also linked to __towatch for Decoda support | 9 | * new method linda:dump() that outputs the full contents of a linda as a table, also linked to __towatch for Decoda support |
diff --git a/src/keeper.c b/src/keeper.c index b330d67..29f9c71 100644 --- a/src/keeper.c +++ b/src/keeper.c | |||
@@ -496,7 +496,11 @@ int keepercall_count( lua_State* L) | |||
496 | static struct s_Keeper *GKeepers = NULL; | 496 | static struct s_Keeper *GKeepers = NULL; |
497 | static int GNbKeepers = 0; | 497 | static int GNbKeepers = 0; |
498 | 498 | ||
499 | static void atexit_close_keepers(void) | 499 | #if HAVE_KEEPER_ATEXIT_DESINIT |
500 | static void atexit_close_keepers( void) | ||
501 | #else // HAVE_KEEPER_ATEXIT_DESINIT | ||
502 | void close_keepers( void) | ||
503 | #endif // HAVE_KEEPER_ATEXIT_DESINIT | ||
500 | { | 504 | { |
501 | int i; | 505 | int i; |
502 | // 2-pass close, in case a keeper holds a reference to a linda bound to another keeoer | 506 | // 2-pass close, in case a keeper holds a reference to a linda bound to another keeoer |
@@ -579,10 +583,9 @@ char const* init_keepers( int const _nbKeepers, lua_CFunction _on_state_create) | |||
579 | GKeepers[i].L = K; | 583 | GKeepers[i].L = K; |
580 | //GKeepers[i].count = 0; | 584 | //GKeepers[i].count = 0; |
581 | } | 585 | } |
582 | // call close_keepers at the very last as we want to be sure no thread is GCing after. | 586 | #if HAVE_KEEPER_ATEXIT_DESINIT |
583 | // (and therefore may perform linda object dereferencing after keepers are gone) | ||
584 | // problem: maybe on some platforms atexit() is called after DLL/so are unloaded... | ||
585 | atexit( atexit_close_keepers); | 587 | atexit( atexit_close_keepers); |
588 | #endif // HAVE_KEEPER_ATEXIT_DESINIT | ||
586 | return NULL; // ok | 589 | return NULL; // ok |
587 | } | 590 | } |
588 | 591 | ||
diff --git a/src/keeper.h b/src/keeper.h index a9b5a22..decae4a 100644 --- a/src/keeper.h +++ b/src/keeper.h | |||
@@ -8,7 +8,16 @@ struct s_Keeper | |||
8 | //int count; | 8 | //int count; |
9 | }; | 9 | }; |
10 | 10 | ||
11 | // if enabled, call close_keepers at the very last as we want to be sure no thread is GCing after. | ||
12 | // (and therefore may perform linda object dereferencing after keepers are gone) | ||
13 | // problem: maybe on some platforms (linux) atexit() is called after DLL/so are unloaded... | ||
14 | #define HAVE_KEEPER_ATEXIT_DESINIT 0 | ||
15 | |||
11 | char const* init_keepers( int const _nbKeepers, lua_CFunction _on_state_create); | 16 | char const* init_keepers( int const _nbKeepers, lua_CFunction _on_state_create); |
17 | #if !HAVE_KEEPER_ATEXIT_DESINIT | ||
18 | void close_keepers( void); | ||
19 | #endif // HAVE_KEEPER_ATEXIT_DESINIT | ||
20 | |||
12 | void populate_keepers( lua_State *L); | 21 | void populate_keepers( lua_State *L); |
13 | struct s_Keeper *keeper_acquire( const void *ptr); | 22 | struct s_Keeper *keeper_acquire( const void *ptr); |
14 | void keeper_release( struct s_Keeper *K); | 23 | void keeper_release( struct s_Keeper *K); |
diff --git a/src/lanes.c b/src/lanes.c index 092e282..e0374cc 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -1317,6 +1317,9 @@ static int selfdestruct_gc( lua_State *L) | |||
1317 | DEBUGEXEC(fprintf( stderr, "Killed %d lane(s) at process end.\n", n )); | 1317 | DEBUGEXEC(fprintf( stderr, "Killed %d lane(s) at process end.\n", n )); |
1318 | #endif | 1318 | #endif |
1319 | } | 1319 | } |
1320 | #if !HAVE_KEEPER_ATEXIT_DESINIT | ||
1321 | close_keepers(); | ||
1322 | #endif // !HAVE_KEEPER_ATEXIT_DESINIT | ||
1320 | return 0; | 1323 | return 0; |
1321 | } | 1324 | } |
1322 | 1325 | ||