summaryrefslogtreecommitdiff
path: root/lib/xray/xray_fdr_logging.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xray/xray_fdr_logging.cc')
-rw-r--r--lib/xray/xray_fdr_logging.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc
index 7aebcb224..bd79893f6 100644
--- a/lib/xray/xray_fdr_logging.cc
+++ b/lib/xray/xray_fdr_logging.cc
@@ -116,6 +116,16 @@ XRayLogFlushStatus fdrLoggingFlush() XRAY_NEVER_INSTRUMENT {
reinterpret_cast<char *>(B.Buffer) + B.Size);
}
});
+
+ // The buffer for this particular thread would have been finalised after
+ // we've written everything to disk, and we'd lose the thread's trace.
+ auto &TLD = __xray::__xray_fdr_internal::getThreadLocalData();
+ if (TLD.Buffer.Buffer != nullptr) {
+ __xray::__xray_fdr_internal::writeEOBMetadata();
+ auto Start = reinterpret_cast<char *>(TLD.Buffer.Buffer);
+ retryingWriteAll(Fd, Start, Start + TLD.Buffer.Size);
+ }
+
__sanitizer::atomic_store(&LogFlushStatus,
XRayLogFlushStatus::XRAY_LOG_FLUSHED,
__sanitizer::memory_order_release);