File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,7 @@ void NodeTraceWriter::WriteSuffix() {
3737 {
3838 Mutex::ScopedLock scoped_lock (stream_mutex_);
3939 if (total_traces_ > 0 ) {
40- total_traces_ = 0 ; // so we don't write it again in FlushPrivate
41- // Appends "]}" to stream_.
42- delete json_trace_writer_;
40+ total_traces_ = kTracesPerFile ; // Act as if we reached the file limit.
4341 should_flush = true ;
4442 }
4543 }
@@ -111,7 +109,7 @@ void NodeTraceWriter::AppendTraceEvent(TraceObject* trace_event) {
111109 // to a state where we can start writing trace events to it.
112110 // Repeatedly constructing and destroying json_trace_writer_ allows
113111 // us to use V8's JSON writer instead of implementing our own.
114- json_trace_writer_ = TraceWriter::CreateJSONTraceWriter (stream_);
112+ json_trace_writer_. reset ( TraceWriter::CreateJSONTraceWriter (stream_) );
115113 }
116114 ++total_traces_;
117115 json_trace_writer_->AppendTraceEvent (trace_event);
@@ -126,7 +124,7 @@ void NodeTraceWriter::FlushPrivate() {
126124 total_traces_ = 0 ;
127125 // Destroying the member JSONTraceWriter object appends "]}" to
128126 // stream_ - in other words, ending a JSON file.
129- delete json_trace_writer_;
127+ json_trace_writer_. reset () ;
130128 }
131129 // str() makes a copy of the contents of the stream.
132130 str = stream_.str ();
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ class NodeTraceWriter : public AsyncTraceWriter {
6363 int file_num_ = 0 ;
6464 const std::string& log_file_pattern_;
6565 std::ostringstream stream_;
66- TraceWriter* json_trace_writer_ = nullptr ;
66+ std::unique_ptr< TraceWriter> json_trace_writer_;
6767 bool exited_ = false ;
6868};
6969
You can’t perform that action at this time.
0 commit comments