Skip to content

Commit

Permalink
fix: stop request before clear environment_data
Browse files Browse the repository at this point in the history
PR-URL: #146
  • Loading branch information
hyj1991 authored Mar 13, 2022
1 parent 02d8b07 commit 46bf2cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/environment_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ EnvironmentData::EnvironmentData(v8::Isolate* isolate, uv_loop_t* loop)

void EnvironmentData::AtExit(void* arg) {
// TODO(legendecas): environment registry.
// The log_by_pass thread should not be bound to a single environment data.
// For now we just destroy the log_by_pass thread since this is the last env.
if (per_process::process_data.log_by_pass != nullptr) {
per_process::process_data.log_by_pass->Join();
per_process::process_data.log_by_pass.reset();
}
per_process::process_data.environment_data.reset();
}

Expand Down
4 changes: 2 additions & 2 deletions src/logbypass/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void LogByPass::ThreadEntry(uv_loop_t* loop) {
CHECK_EQ(0, uv_timer_init(loop, &cpu_interval_));
CHECK_EQ(0, uv_timer_init(loop, &log_interval_));

CHECK_EQ(0, uv_timer_start(&cpu_interval_, OnCpuInterval, 1000, true));
CHECK_EQ(0, uv_timer_start(&cpu_interval_, OnCpuInterval, 1000, 1000));
CHECK_EQ(0, uv_timer_start(&log_interval_, OnLogInterval,
GetLogInterval() * 1000, false));
}
Expand Down Expand Up @@ -85,4 +85,4 @@ void RunLogBypass(const FunctionCallbackInfo<Value>& info) {
info.GetReturnValue().Set(True());
}

} // namespace xprofiler
} // namespace xprofiler

0 comments on commit 46bf2cb

Please sign in to comment.