Skip to content

Commit

Permalink
Re-init logger lock after fork.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 23, 2016
1 parent 29f702e commit 17f6450
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions machine/environment.cpp
Expand Up @@ -218,6 +218,7 @@ namespace rubinius {
}

void Environment::start_logging(STATE) {
utilities::logger::init();
utilities::logger::logger_level level = utilities::logger::eWarn;

if(!config.system_log_level.value.compare("fatal")) {
Expand Down Expand Up @@ -581,10 +582,10 @@ namespace rubinius {
}

void Environment::halt(STATE, int exit_code) {
utilities::thread::Mutex::LockGuard guard(halt_lock_);

utilities::logger::write("exit process: %s %d", shared->pid.c_str(), exit_code);

utilities::thread::Mutex::LockGuard guard(halt_lock_);

state->shared().tool_broker()->shutdown(state);

if(Memory* om = state->memory()) {
Expand Down
4 changes: 4 additions & 0 deletions machine/util/logger.cpp
Expand Up @@ -23,6 +23,10 @@ namespace rubinius {
static Logger* logger_ = 0;
static logger_level loglevel_ = eWarn;

void init() {
lock_.init();
}

void open(logger_type type, const char* identifier, logger_level level, ...) {
lock_.init();
va_list varargs;
Expand Down
1 change: 1 addition & 0 deletions machine/util/logger.hpp
Expand Up @@ -32,6 +32,7 @@ namespace rubinius {
void info(const char* message, ...);
void debug(const char* message, ...);

void init();
void set_label();
void set_loglevel(logger_level level);

Expand Down
1 change: 1 addition & 0 deletions machine/vm.cpp
Expand Up @@ -286,6 +286,7 @@ namespace rubinius {
}

void VM::after_fork_child(STATE) {
utilities::logger::init();
utilities::logger::set_label();

thread_nexus_->after_fork_child(state);
Expand Down

0 comments on commit 17f6450

Please sign in to comment.