Skip to content

Commit 0141e9e

Browse files
authored
Only store failed SignalSyncs (#3128)
1 parent 1332712 commit 0141e9e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/bthread/task_tracer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ TaskTracer::Result TaskTracer::SignalTrace(pthread_t worker_tid) {
410410
return Result::MakeErrorResult("Fail to pthread_sigqueue: %s", berror());
411411
}
412412
}
413-
_inuse_signal_syncs.push_back(signal_sync);
414413

415414
// Wait for the signal handler to complete.
416415
butil::Timer timer;
@@ -435,13 +434,14 @@ TaskTracer::Result TaskTracer::SignalTrace(pthread_t worker_tid) {
435434
if (EINTR == errno) {
436435
continue;
437436
}
437+
// Extend the lifetime of `signal_sync' to
438+
// avoid it being destroyed in the signal handler.
439+
_inuse_signal_syncs.push_back(signal_sync);
438440
return Result::MakeErrorResult("Fail to poll: %s", berror());
439441
}
440442
break;
441443
}
442-
// Remove the successful SignalSync.
443-
_inuse_signal_syncs.pop_back();
444-
444+
445445
return signal_sync->result;
446446
}
447447

0 commit comments

Comments
 (0)