Commit b27bcdd6bc8 by Armin Rigo

Need to fflush the stm.log file before a fork().

--HG--
branch : hashtable
parent ece6317ba18
......@@ -201,9 +201,6 @@ static void forksupport_child(void)
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
*/
......
......@@ -74,7 +74,13 @@ static bool close_timing_log(void)
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 @@ int stm_set_timing_log(const char *profiling_file_name,
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;
......
static void forksupport_open_new_profiling_file(void);
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment