mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: nullcheck on trace controller
Insert a NULLCHECK prior to return. Ideally we do this in the caller, but the TraceController object is somewhat special as: 1. It is accessed by most threads 2. It's life cycle is managed by Agent::Agent 3. It's getter is invoked through Base Methods (upstream) Refs: https://github.com/nodejs/node/issues/25814 PR-URL: https://github.com/nodejs/node/pull/25943 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
committed by
Anna Henningsen
parent
3a4521a4a2
commit
c70e853723
@@ -208,8 +208,7 @@ Environment::Environment(IsolateData* isolate_data,
|
||||
if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) {
|
||||
trace_state_observer_ = std::make_unique<TrackingTraceStateObserver>(this);
|
||||
TracingController* tracing_controller = writer->GetTracingController();
|
||||
if (tracing_controller != nullptr)
|
||||
tracing_controller->AddTraceStateObserver(trace_state_observer_.get());
|
||||
tracing_controller->AddTraceStateObserver(trace_state_observer_.get());
|
||||
}
|
||||
|
||||
destroy_async_id_list_.reserve(512);
|
||||
@@ -272,8 +271,7 @@ Environment::~Environment() {
|
||||
tracing::AgentWriterHandle* writer = GetTracingAgentWriter();
|
||||
CHECK_NOT_NULL(writer);
|
||||
TracingController* tracing_controller = writer->GetTracingController();
|
||||
if (tracing_controller != nullptr)
|
||||
tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get());
|
||||
tracing_controller->RemoveTraceStateObserver(trace_state_observer_.get());
|
||||
}
|
||||
|
||||
delete[] heap_statistics_buffer_;
|
||||
|
||||
@@ -459,6 +459,7 @@ double NodePlatform::CurrentClockTimeMillis() {
|
||||
}
|
||||
|
||||
TracingController* NodePlatform::GetTracingController() {
|
||||
CHECK_NOT_NULL(tracing_controller_);
|
||||
return tracing_controller_;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ class Agent {
|
||||
~Agent();
|
||||
|
||||
TracingController* GetTracingController() {
|
||||
return tracing_controller_.get();
|
||||
TracingController* controller = tracing_controller_.get();
|
||||
CHECK_NOT_NULL(controller);
|
||||
return controller;
|
||||
}
|
||||
|
||||
enum UseDefaultCategoryMode {
|
||||
|
||||
Reference in New Issue
Block a user