diff options
| author | Benoit Germain <bnt.germain@gmail.com> | 2013-10-25 10:46:59 +0200 |
|---|---|---|
| committer | Benoit Germain <bnt.germain@gmail.com> | 2013-10-25 10:46:59 +0200 |
| commit | a00a9345456762a132dc19b6a470c55d55b064f9 (patch) | |
| tree | 2b9f57b8094ae90fc77e17c8874d175132dd8fce /src | |
| parent | e7f70c05b63356232957a3205c6c605f0839605b (diff) | |
| download | lanes-a00a9345456762a132dc19b6a470c55d55b064f9.tar.gz lanes-a00a9345456762a132dc19b6a470c55d55b064f9.tar.bz2 lanes-a00a9345456762a132dc19b6a470c55d55b064f9.zip | |
Don't call on_state_create in keeper states, as it is no longer necessary
Diffstat (limited to 'src')
| -rw-r--r-- | src/keeper.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/keeper.c b/src/keeper.c index c9b2039..e379172 100644 --- a/src/keeper.c +++ b/src/keeper.c | |||
| @@ -567,31 +567,27 @@ void close_keepers( void) | |||
| 567 | */ | 567 | */ |
| 568 | char const* init_keepers( lua_State* L) | 568 | char const* init_keepers( lua_State* L) |
| 569 | { | 569 | { |
| 570 | int i, on_state_create; | 570 | int i; |
| 571 | void* allocUD; | ||
| 572 | lua_Alloc allocF = lua_getallocf( L, &allocUD); | ||
| 573 | |||
| 571 | STACK_CHECK( L); | 574 | STACK_CHECK( L); |
| 572 | lua_getfield( L, 1, "nb_keepers"); | 575 | lua_getfield( L, 1, "nb_keepers"); |
| 573 | GNbKeepers = lua_tointeger( L, -1); | 576 | GNbKeepers = lua_tointeger( L, -1); |
| 574 | lua_pop( L, 1); | 577 | lua_pop( L, 1); |
| 575 | STACK_MID( L, 0); | 578 | STACK_END( L, 0); |
| 576 | assert( GNbKeepers >= 1); | 579 | assert( GNbKeepers >= 1); |
| 577 | 580 | ||
| 578 | lua_getfield( L, 1, "on_state_create"); | ||
| 579 | on_state_create = lua_isnil( L, -1) ? -1 : lua_absindex( L, -1); | ||
| 580 | |||
| 581 | GKeepers = malloc( GNbKeepers * sizeof( struct s_Keeper)); | 581 | GKeepers = malloc( GNbKeepers * sizeof( struct s_Keeper)); |
| 582 | for( i = 0; i < GNbKeepers; ++ i) | 582 | for( i = 0; i < GNbKeepers; ++ i) |
| 583 | { | 583 | { |
| 584 | lua_State* K; | 584 | lua_State* K = lua_newstate( allocF, allocUD); |
| 585 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "### init_keepers %d BEGIN\n" INDENT_END, i)); | 585 | if( K == NULL) |
| 586 | DEBUGSPEW_CODE( ++ debugspew_indent_depth); | 586 | { |
| 587 | // we don't need any libs in the keeper states | 587 | (void) luaL_error( L, "'lua_newstate()' failed while creating keeper state; out of memory"); |
| 588 | K = luaG_newstate( L, on_state_create, NULL); | 588 | } |
| 589 | |||
| 590 | STACK_CHECK( K); | 589 | STACK_CHECK( K); |
| 591 | 590 | ||
| 592 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "### init_keepers %d END\n" INDENT_END, i)); | ||
| 593 | DEBUGSPEW_CODE( -- debugspew_indent_depth); | ||
| 594 | |||
| 595 | // to see VM name in Decoda debugger | 591 | // to see VM name in Decoda debugger |
| 596 | lua_pushliteral( K, "Keeper #"); | 592 | lua_pushliteral( K, "Keeper #"); |
| 597 | lua_pushinteger( K, i + 1); | 593 | lua_pushinteger( K, i + 1); |
| @@ -606,14 +602,11 @@ char const* init_keepers( lua_State* L) | |||
| 606 | STACK_END( K, 0); | 602 | STACK_END( K, 0); |
| 607 | MUTEX_INIT( &GKeepers[i].lock_); | 603 | MUTEX_INIT( &GKeepers[i].lock_); |
| 608 | GKeepers[i].L = K; | 604 | GKeepers[i].L = K; |
| 609 | //GKeepers[i].count = 0; | ||
| 610 | } | 605 | } |
| 611 | lua_pop( L, 1); | ||
| 612 | STACK_END( L, 0); | ||
| 613 | #if HAVE_KEEPER_ATEXIT_DESINIT | 606 | #if HAVE_KEEPER_ATEXIT_DESINIT |
| 614 | atexit( atexit_close_keepers); | 607 | atexit( atexit_close_keepers); |
| 615 | #endif // HAVE_KEEPER_ATEXIT_DESINIT | 608 | #endif // HAVE_KEEPER_ATEXIT_DESINIT |
| 616 | return NULL; // ok | 609 | return NULL; // ok |
| 617 | } | 610 | } |
| 618 | 611 | ||
| 619 | struct s_Keeper* keeper_acquire( void const* ptr) | 612 | struct s_Keeper* keeper_acquire( void const* ptr) |
