aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2013-03-14 22:13:30 +0100
committerBenoit Germain <bnt.germain@gmail.com>2013-03-14 22:13:30 +0100
commit0d9ede58ddb4c357e2f3aedc2a05ca17c5028c31 (patch)
treefe3ee8bde4691b2e4adb25d6a1d9c52655064f90 /src
parent8fb8dc1edeceae9fff65463cd80da05d8995fb7f (diff)
downloadlanes-0d9ede58ddb4c357e2f3aedc2a05ca17c5028c31.tar.gz
lanes-0d9ede58ddb4c357e2f3aedc2a05ca17c5028c31.tar.bz2
lanes-0d9ede58ddb4c357e2f3aedc2a05ca17c5028c31.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/lanes.c27
1 files changed, 14 insertions, 13 deletions
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 @@
52 * ... 52 * ...
53 */ 53 */
54 54
55char const* VERSION = "3.5.2"; 55char const* VERSION = "3.6.0";
56 56
57/* 57/*
58=============================================================================== 58===============================================================================
@@ -2611,7 +2611,7 @@ void register_core_libfuncs_for_keeper( lua_State* L)
2611/* 2611/*
2612** One-time initializations 2612** One-time initializations
2613*/ 2613*/
2614static 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) 2614static void init_once_LOCKED( lua_State* L, int const _on_state_create, int const nbKeepers, lua_Number _shutdown_timeout, bool_t _track_lanes)
2615{ 2615{
2616#if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) 2616#if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC)
2617 now_secs(); // initialize 'now_secs()' internal offset 2617 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
2621 chudInitialize(); 2621 chudInitialize();
2622#endif 2622#endif
2623 2623
2624 if( _protect_allocator)
2625 {
2626 void* ud;
2627 lua_Alloc allocf = lua_getallocf( L, &ud);
2628 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) allocf( ud, NULL, 0, sizeof( struct ProtectedAllocator_s));
2629 s->allocf = allocf;
2630 s->ud = ud;
2631 MUTEX_INIT( &s->lock);
2632 lua_setallocf( L, protected_lua_Alloc, s);
2633 }
2634
2635#if HAVE_LANE_TRACKING 2624#if HAVE_LANE_TRACKING
2636 tracking_first = _track_lanes ? TRACKING_END : NULL; 2625 tracking_first = _track_lanes ? TRACKING_END : NULL;
2637#endif // HAVE_LANE_TRACKING 2626#endif // HAVE_LANE_TRACKING
@@ -2744,6 +2733,18 @@ LUAG_FUNC( configure)
2744 DEBUGSPEW_CODE( ++ debugspew_indent_depth); 2733 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
2745 STACK_CHECK( L); 2734 STACK_CHECK( L);
2746 2735
2736 // not in init_once_LOCKED because we can have several hosted "master" Lua states where Lanes is require()d.
2737 if( protect_allocator)
2738 {
2739 void* ud;
2740 lua_Alloc allocf = lua_getallocf( L, &ud);
2741 struct ProtectedAllocator_s* s = (struct ProtectedAllocator_s*) allocf( ud, NULL, 0, sizeof( struct ProtectedAllocator_s));
2742 s->allocf = allocf;
2743 s->ud = ud;
2744 MUTEX_INIT( &s->lock);
2745 lua_setallocf( L, protected_lua_Alloc, s);
2746 }
2747
2747 // Create main module interface table 2748 // Create main module interface table
2748 lua_pushvalue( L, lua_upvalueindex( 2)); // ... M 2749 lua_pushvalue( L, lua_upvalueindex( 2)); // ... M
2749 // remove configure() (this function) from the module interface 2750 // remove configure() (this function) from the module interface