Skip to content

Commit b93584b

Browse files
committed
src: refactor tracing_agent into v8_platform
Move tracing_agent global into the v8_platform struct, renaming it to tracing_agent_; CHECK(tracing_agent_ == nullptr) in StartTracingAgent() to detect double calls; and relace another tracing_agent->Stop() call with a call to StopTracingAgent().
1 parent 0e9c0cb commit b93584b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/node.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ static uv_async_t dispatch_debug_messages_async;
200200

201201
static Mutex node_isolate_mutex;
202202
static v8::Isolate* node_isolate;
203-
static tracing::Agent* tracing_agent;
204203

205204
static node::DebugOptions debug_options;
206205

@@ -229,15 +228,17 @@ static struct {
229228
#endif // HAVE_INSPECTOR
230229

231230
void StartTracingAgent() {
232-
tracing_agent = new tracing::Agent();
233-
tracing_agent->Start(platform_, trace_enabled_categories);
231+
CHECK(tracing_agent_ == nullptr);
232+
tracing_agent_ = new tracing::Agent();
233+
tracing_agent_->Start(platform_, trace_enabled_categories);
234234
}
235235

236236
void StopTracingAgent() {
237-
tracing_agent->Stop();
237+
tracing_agent_->Stop();
238238
}
239239

240240
v8::Platform* platform_;
241+
tracing::Agent* tracing_agent_;
241242
#else // !NODE_USE_V8_PLATFORM
242243
void Initialize(int thread_pool_size) {}
243244
void PumpMessageLoop(Isolate* isolate) {}
@@ -3401,7 +3402,7 @@ void SetupProcessObject(Environment* env,
34013402
void SignalExit(int signo) {
34023403
uv_tty_reset_mode();
34033404
if (trace_enabled) {
3404-
tracing_agent->Stop();
3405+
v8_platform.StopTracingAgent();
34053406
}
34063407
#ifdef __FreeBSD__
34073408
// FreeBSD has a nasty bug, see RegisterSignalHandler for details

0 commit comments

Comments
 (0)