mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Fix tsan and asan errors.
PiperOrigin-RevId: 656481180
This commit is contained in:
committed by
Copybara-Service
parent
0be7045809
commit
2bbef70dcd
@@ -47,6 +47,12 @@ TransferManager::TransferManager(Context* context,
|
||||
absl::string_view endpoint_id)
|
||||
: context_(context), endpoint_id_(endpoint_id) {}
|
||||
|
||||
TransferManager::~TransferManager() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
timeout_timer_.reset();
|
||||
pending_tasks_.clear();
|
||||
}
|
||||
|
||||
void TransferManager::Send(std::function<void()> task) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
@@ -100,8 +106,7 @@ bool TransferManager::StartTransfer() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NL_LOG(INFO) << "Timed out for endpoint " << endpoint_id_ << " after "
|
||||
<< (kMediumUpgradeTimeout / absl::Milliseconds(1))
|
||||
<< "ms.";
|
||||
<< kMediumUpgradeTimeout;
|
||||
StopWaitingForHighQualityMedium();
|
||||
});
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ class TransferManager {
|
||||
|
||||
TransferManager(Context* context, absl::string_view endpoint_id);
|
||||
|
||||
~TransferManager();
|
||||
|
||||
void Send(std::function<void()> task) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnMediumQualityChanged(Medium current_medium)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
@@ -51,12 +53,11 @@ class TransferManager {
|
||||
void StopWaitingForHighQualityMedium() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
Context* context_;
|
||||
bool is_waiting_for_high_quality_medium_ = true;
|
||||
std::string endpoint_id_;
|
||||
absl::Mutex mutex_;
|
||||
bool is_waiting_for_high_quality_medium_ ABSL_GUARDED_BY(mutex_) = true;
|
||||
std::vector<std::function<void()>> pending_tasks_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
std::unique_ptr<ThreadTimer> timeout_timer_ = nullptr;
|
||||
std::unique_ptr<ThreadTimer> timeout_timer_ ABSL_GUARDED_BY(mutex_) = nullptr;
|
||||
};
|
||||
|
||||
} // namespace sharing
|
||||
|
||||
Reference in New Issue
Block a user