From 0d9ede58ddb4c357e2f3aedc2a05ca17c5028c31 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 14 Mar 2013 22:13:30 +0100 Subject: version 3.6.0 * protect_allocator is an API change -> version bump * bugfix: allocator protection should be done once per primary Lua state, not once only the first time ever Lanes is required --- CHANGES | 5 +++++ docs/index.html | 2 +- src/lanes.c | 27 ++++++++++++++------------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index a697838..911705e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ CHANGES: +CHANGE 61: BGe 14-Mar-13 + * version 3.6.0 + * protect_allocator is an API change -> version bump + * bugfix: allocator protection should be done once per primary Lua state, not once only the first time ever Lanes is required + CHANGE 60: BGe 13-Mar-13 * version 3.5.2 * stricter validation of with_timers config option: validator was accepting any non-boolean value diff --git a/docs/index.html b/docs/index.html index 98c1d3d..c65a17a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -70,7 +70,7 @@

- This document was revised on 13-Mar-13, and applies to version 3.5.2. + This document was revised on 14-Mar-13, and applies to version 3.6.0.

diff --git a/src/lanes.c b/src/lanes.c index d058cde..d4bd105 100644 --- a/src/lanes.c +++ b/src/lanes.c @@ -52,7 +52,7 @@ * ... */ -char const* VERSION = "3.5.2"; +char const* VERSION = "3.6.0"; /* =============================================================================== @@ -2611,7 +2611,7 @@ void register_core_libfuncs_for_keeper( lua_State* L) /* ** One-time initializations */ -static void init_once_LOCKED( lua_State* L, int const _on_state_create, int const nbKeepers, lua_Number _shutdown_timeout, bool_t _track_lanes, bool_t _protect_allocator) +static void init_once_LOCKED( lua_State* L, int const _on_state_create, int const nbKeepers, lua_Number _shutdown_timeout, bool_t _track_lanes) { #if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) now_secs(); // initialize 'now_secs()' internal offset @@ -2621,17 +2621,6 @@ static void init_once_LOCKED( lua_State* L, int const _on_state_create, int cons chudInitialize(); #endif - if( _protect_allocator) - { - void* ud; - lua_Alloc allocf = lua_getallocf( L, &ud); - struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) allocf( ud, NULL, 0, sizeof( struct ProtectedAllocator_s)); - s->allocf = allocf; - s->ud = ud; - MUTEX_INIT( &s->lock); - lua_setallocf( L, protected_lua_Alloc, s); - } - #if HAVE_LANE_TRACKING tracking_first = _track_lanes ? TRACKING_END : NULL; #endif // HAVE_LANE_TRACKING @@ -2744,6 +2733,18 @@ LUAG_FUNC( configure) DEBUGSPEW_CODE( ++ debugspew_indent_depth); STACK_CHECK( L); + // not in init_once_LOCKED because we can have several hosted "master" Lua states where Lanes is require()d. + if( protect_allocator) + { + void* ud; + lua_Alloc allocf = lua_getallocf( L, &ud); + struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) allocf( ud, NULL, 0, sizeof( struct ProtectedAllocator_s)); + s->allocf = allocf; + s->ud = ud; + MUTEX_INIT( &s->lock); + lua_setallocf( L, protected_lua_Alloc, s); + } + // Create main module interface table lua_pushvalue( L, lua_upvalueindex( 2)); // ... M // remove configure() (this function) from the module interface -- cgit v1.2.3-55-g6feb