about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <mwrap-perl@80x24.org>2022-09-04 07:44:42 +0000
committerEric Wong <e@80x24.org>2022-09-15 17:39:04 +0000
commit3197316f33fdc5d487c5bdbb9eb029d443d3c8bf (patch)
treed2fc84e8396284c86420a65edf927f5d6e5f9722
parent5b3ff6f67c97a77809072065e4cafe544609922c (diff)
downloadmwrap-3197316f33fdc5d487c5bdbb9eb029d443d3c8bf.tar.gz
This allows us to start tracking allocations before Perl calls
our BOOT code, which can be far later if it has to boot other
modules first.  As an LD_PRELOAD, the constructor can fire
before Perl's main().
-rw-r--r--Mwrap.xs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Mwrap.xs b/Mwrap.xs
index 510e211..092aaf4 100644
--- a/Mwrap.xs
+++ b/Mwrap.xs
@@ -144,6 +144,10 @@ __attribute__((constructor)) static void resolve_malloc(void)
                 }
 #endif /* !__FreeBSD__ */
         }
+        CMM_STORE_SHARED(totals, lfht_new());
+        if (!CMM_LOAD_SHARED(totals))
+                fprintf(stderr, "failed to allocate totals table\n");
+
         err = pthread_atfork(call_rcu_before_fork,
                                 call_rcu_after_fork_parent,
                                 call_rcu_after_fork_child);
@@ -805,9 +809,6 @@ BOOT:
 #ifndef PERL_IMPLICIT_CONTEXT
         root_locating = &locating;
 #endif
-        CMM_STORE_SHARED(totals, lfht_new());
-        if (!CMM_LOAD_SHARED(totals))
-                fprintf(stderr, "failed to allocate totals table\n");
 
 PROTOTYPES: ENABLE