Skip to content

Commit

Permalink
Fix TSAN issue due to std::chrono non atomic access
Browse files Browse the repository at this point in the history
Summary: Fix TSAN issue due to std::chrono non atomic access

Reviewed By: danobi

Differential Revision: D29903190

fbshipit-source-id: 31c574741542cc6303d01b42a74ef5d30ebc7e04
  • Loading branch information
dmm-fb authored and facebook-github-bot committed Jul 26, 2021
1 parent b98479c commit 7c44f79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Receiver.cpp
Expand Up @@ -82,7 +82,7 @@ void Receiver::startNewGlobalSession(const std::string &peerIp) {
// when the current session ends
throttler_->startTransfer();
}
startTime_ = Clock::now();
startTime_.store(Clock::now());
if (options_.enable_download_resumption) {
transferLogManager_->startThread();
bool verifySuccessful = transferLogManager_->verifySenderIp(peerIp);
Expand Down Expand Up @@ -325,7 +325,7 @@ std::unique_ptr<TransferReport> Receiver::finish() {
auto totalSenderBytes = summary.getTotalSenderBytes();
if (progressReporter_ && totalSenderBytes >= 0) {
report->setTotalFileSize(totalSenderBytes);
report->setTotalTime(durationSeconds(Clock::now() - startTime_));
report->setTotalTime(durationSeconds(Clock::now() - startTime_.load()));
progressReporter_->end(report);
}
logPerfStats();
Expand Down Expand Up @@ -407,7 +407,7 @@ void Receiver::progressTracker() {
break;
}
}
double totalTime = durationSeconds(Clock::now() - startTime_);
double totalTime = durationSeconds(Clock::now() - startTime_.load());
TransferStats globalStats;
for (const auto &receiverThread : receiverThreads_) {
globalStats += receiverThread->getTransferStats();
Expand Down
2 changes: 1 addition & 1 deletion Receiver.h
Expand Up @@ -203,7 +203,7 @@ class Receiver : public WdtBase {
std::vector<Checkpoint> checkpoints_;

/// Start time of the session
std::chrono::time_point<Clock> startTime_;
std::atomic<std::chrono::time_point<Clock>> startTime_;

/// already transferred file chunks
std::vector<FileChunksInfo> fileChunksInfo_;
Expand Down

0 comments on commit 7c44f79

Please sign in to comment.