aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeper.c')
-rw-r--r--src/keeper.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/keeper.c b/src/keeper.c
index 7485110..3511b56 100644
--- a/src/keeper.c
+++ b/src/keeper.c
@@ -557,7 +557,7 @@ void close_keepers( void)
557* unclosed, because it does not really matter. In production code, this 557* unclosed, because it does not really matter. In production code, this
558* function never fails. 558* function never fails.
559*/ 559*/
560char const* init_keepers( lua_State* L, int const _nbKeepers, lua_CFunction _on_state_create) 560char const* init_keepers( lua_State* L, int _on_state_create, int const _nbKeepers)
561{ 561{
562 int i; 562 int i;
563 assert( _nbKeepers >= 1); 563 assert( _nbKeepers >= 1);
@@ -572,7 +572,7 @@ char const* init_keepers( lua_State* L, int const _nbKeepers, lua_CFunction _on_
572 // 572 //
573 // 'io' for debugging messages, 'package' because we need to require modules exporting idfuncs 573 // 'io' for debugging messages, 'package' because we need to require modules exporting idfuncs
574 // the others because they export functions that we may store in a keeper for transfer between lanes 574 // the others because they export functions that we may store in a keeper for transfer between lanes
575 K = luaG_newstate( L, "*", _on_state_create); 575 K = luaG_newstate( L, _on_state_create, "*");
576 576
577 STACK_CHECK( K); 577 STACK_CHECK( K);
578 578
@@ -635,8 +635,8 @@ void populate_keepers( lua_State* L)
635 char const* name = luaL_checklstring( L, -1, &name_len); 635 char const* name = luaL_checklstring( L, -1, &name_len);
636 int i; 636 int i;
637 637
638 STACK_CHECK( L); 638 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "populate_keepers %s BEGIN\n" INDENT_END, name));
639 STACK_GROW( L, 3); 639 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
640 640
641 for( i = 0; i < GNbKeepers; ++ i) 641 for( i = 0; i < GNbKeepers; ++ i)
642 { 642 {
@@ -647,16 +647,19 @@ void populate_keepers( lua_State* L)
647 STACK_GROW( K, 2); 647 STACK_GROW( K, 2);
648 lua_getglobal( K, "require"); 648 lua_getglobal( K, "require");
649 lua_pushlstring( K, name, name_len); 649 lua_pushlstring( K, name, name_len);
650 res = lua_pcall( K, 1, 0, 0); 650 res = lua_pcall( K, 1, 1, 0);
651 if( res != LUA_OK) 651 if( res != LUA_OK)
652 { 652 {
653 char const* err = luaL_checkstring( K, -1); 653 char const* err = luaL_checkstring( K, -1);
654 luaL_error( L, "error requiring '%s' in keeper state: %s", name, err); 654 luaL_error( L, "error requiring '%s' in keeper state: %s", name, err);
655 } 655 }
656 // after requiring the module, register the functions it exported in our name<->function database
657 populate_func_lookup_table( K, -1, name);
658 lua_pop( K, 1);
656 STACK_END( K, 0); 659 STACK_END( K, 0);
657 MUTEX_UNLOCK( &GKeepers[i].lock_); 660 MUTEX_UNLOCK( &GKeepers[i].lock_);
658 } 661 }
659 STACK_END( L, 0); 662 DEBUGSPEW_CODE( -- debugspew_indent_depth);
660} 663}
661 664
662struct s_Keeper* keeper_acquire( void const* ptr) 665struct s_Keeper* keeper_acquire( void const* ptr)