--- Coro-Multicore/Multicore.xs 2015/12/19 23:56:35 1.15 +++ Coro-Multicore/Multicore.xs 2016/01/24 04:20:49 1.16 @@ -24,7 +24,13 @@ #define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv) #endif +#define RECURSION_CHECK 0 + static X_TLS_DECLARE(current_key); +#if RECURSION_CHECK +static X_TLS_DECLARE(check_key); +#endif + static s_epipe ep; static void *perl_thx; @@ -175,6 +181,13 @@ static void pmapi_release (void) { + #if RECURSION_CHECK + if (X_TLS_GET (check_key)) + croak ("perlinterp_release () called without valid perl context"); + + X_TLS_SET (check_key, &check_key); + #endif + if (! ((thread_enable ? thread_enable : global_enable) & 1)) { X_TLS_SET (current_key, 0); @@ -211,6 +224,13 @@ int jeret; struct tctx *ctx = X_TLS_GET (current_key); + #if RECURSION_CHECK + if (X_TLS_GET (check_key) != &check_key) + croak ("perlinterp_acquire () called with valid perl context"); + + X_TLS_SET (check_key, 0); + #endif + if (!ctx) return; @@ -243,11 +263,14 @@ BOOT: { - #ifndef _WIN32 +#ifndef _WIN32 sigfillset (&fullsigset); - #endif +#endif X_TLS_INIT (current_key); +#if RECURSION_CHECK + X_TLS_INIT (check_key); +#endif if (s_epipe_new (&ep)) croak ("Coro::Multicore: unable to initialise event pipe.\n");