summaryrefslogtreecommitdiffstats
path: root/src/base.c
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-03-13 23:31:41 (GMT)
committerJason Evans <je@fb.com>2012-03-13 23:31:41 (GMT)
commit4e2e3dd9cf19ed5991938a708a8b50611aa5bbf8 (patch)
tree0bd52cef3ce19d84725e6018a5b41bc6cdb8de2a /src/base.c
parent824d34e5b7f5cf00bf472ec79f7ec1c6e3474114 (diff)
downloadjemalloc-4e2e3dd9cf19ed5991938a708a8b50611aa5bbf8.zip
jemalloc-4e2e3dd9cf19ed5991938a708a8b50611aa5bbf8.tar.gz
jemalloc-4e2e3dd9cf19ed5991938a708a8b50611aa5bbf8.tar.bz2
Fix fork-related bugs.
Acquire/release arena bin locks as part of the prefork/postfork. This bug made deadlock in the child between fork and exec a possibility. Split jemalloc_postfork() into jemalloc_postfork_{parent,child}() so that the child can reinitialize mutexes rather than unlocking them. In practice, this bug tended not to cause problems.
Diffstat (limited to 'src/base.c')
-rw-r--r--src/base.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/base.c b/src/base.c
index cc85e84..eb68334 100644
--- a/src/base.c
+++ b/src/base.c
@@ -4,7 +4,7 @@
/******************************************************************************/
/* Data. */
-malloc_mutex_t base_mtx;
+static malloc_mutex_t base_mtx;
/*
* Current pages that are being used for internal memory allocations. These
@@ -104,3 +104,24 @@ base_boot(void)
return (false);
}
+
+void
+base_prefork(void)
+{
+
+ malloc_mutex_prefork(&base_mtx);
+}
+
+void
+base_postfork_parent(void)
+{
+
+ malloc_mutex_postfork_parent(&base_mtx);
+}
+
+void
+base_postfork_child(void)
+{
+
+ malloc_mutex_postfork_child(&base_mtx);
+}