]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - indirect.xs
Manually release MY_CXT.global_code at interpreter teardown time
[perl/modules/indirect.git] / indirect.xs
index 0de84e5fba5a465f29166e1270f910b236f8e517..ba0543dae7e778c864bac2a9543479f2a2317e53 100644 (file)
@@ -214,7 +214,7 @@ static void indirect_ck_restore(pTHX_ OPCODE type, indirect_ck_t *old_ck_p) {
 
 /* ... Check if the module is loaded ....................................... */
 
-static U32 indirect_loaded = 0;
+static I32 indirect_loaded = 0;
 
 #if I_THREADSAFE
 
@@ -246,6 +246,7 @@ static int indirect_set_loaded_locked(pTHX_ void *cxt) {
  int global_setup = 0;
 
  if (indirect_loaded <= 0) {
+  assert(indirect_loaded == 0);
   assert(!indirect_loaded_cxts);
   indirect_loaded_cxts = ptable_new();
   global_setup         = 1;
@@ -266,6 +267,7 @@ static int indirect_clear_loaded_locked(pTHX_ void *cxt) {
   ptable_loaded_delete(indirect_loaded_cxts, cxt);
   --indirect_loaded;
  } else if (indirect_loaded_cxts) {
+  assert(indirect_loaded == 1);
   ptable_loaded_free(indirect_loaded_cxts);
   indirect_loaded_cxts = NULL;
   indirect_loaded      = 0;
@@ -1065,6 +1067,9 @@ static void indirect_teardown(pTHX_ void *interp) {
 
  I_LOADED_UNLOCK;
 
+ SvREFCNT_dec(MY_CXT.global_code);
+ MY_CXT.global_code = NULL;
+
  ptable_free(MY_CXT.map);
  MY_CXT.map = NULL;