[pypy-commit] stmgc hashtable: Need to fflush the stm.log file before a fork().
arigo
noreply at buildbot.pypy.org
Fri Nov 7 20:02:47 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: hashtable
Changeset: r1499:b27bcdd6bc87
Date: 2014-11-07 20:02 +0100
http://bitbucket.org/pypy/stmgc/changeset/b27bcdd6bc87/
Log: Need to fflush the stm.log file before a fork().
diff --git a/c7/stm/forksupport.c b/c7/stm/forksupport.c
--- a/c7/stm/forksupport.c
+++ b/c7/stm/forksupport.c
@@ -201,9 +201,6 @@
just release these locks early */
s_mutex_unlock();
- /* Open a new profiling file, if any */
- forksupport_open_new_profiling_file();
-
/* Move the copy of the mmap over the old one, overwriting it
and thus freeing the old mapping in this process
*/
diff --git a/c7/stm/prof.c b/c7/stm/prof.c
--- a/c7/stm/prof.c
+++ b/c7/stm/prof.c
@@ -74,7 +74,13 @@
return false;
}
-static void forksupport_open_new_profiling_file(void)
+static void prof_forksupport_prepare(void)
+{
+ if (profiling_file != NULL)
+ fflush(profiling_file);
+}
+
+static void prof_forksupport_child(void)
{
if (close_timing_log() && profiling_basefn != NULL) {
char filename[1024];
@@ -98,6 +104,15 @@
expand_marker = default_expand_marker;
profiling_expand_marker = expand_marker;
+ static bool fork_support_ready = false;
+ if (!fork_support_ready) {
+ int res = pthread_atfork(prof_forksupport_prepare,
+ NULL, prof_forksupport_child);
+ if (res != 0)
+ stm_fatalerror("pthread_atfork() failed: %m");
+ fork_support_ready = true;
+ }
+
if (!open_timing_log(profiling_file_name))
return -1;
diff --git a/c7/stm/prof.h b/c7/stm/prof.h
deleted file mode 100644
--- a/c7/stm/prof.h
+++ /dev/null
@@ -1,2 +0,0 @@
-
-static void forksupport_open_new_profiling_file(void);
diff --git a/c7/stmgc.c b/c7/stmgc.c
--- a/c7/stmgc.c
+++ b/c7/stmgc.c
@@ -15,7 +15,6 @@
#include "stm/fprintcolor.h"
#include "stm/weakref.h"
#include "stm/marker.h"
-#include "stm/prof.h"
#include "stm/finalizer.h"
#include "stm/hashtable.h"
More information about the pypy-commit
mailing list