mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Close BaseEndpointChannel once
Closing the bluetoth socket and streams more than once is wasteful and error prone. PiperOrigin-RevId: 549964135
This commit is contained in:
committed by
Copybara-Service
parent
e0b9ad2c2d
commit
2c08cfc9e8
@@ -265,6 +265,11 @@ void BaseEndpointChannel::Close() {
|
||||
{
|
||||
// In case channel is paused, resume it first thing.
|
||||
MutexLock lock(&is_paused_mutex_);
|
||||
if (is_closed_) {
|
||||
NEARBY_LOGS(VERBOSE) << "EndpointChannel already closed";
|
||||
return;
|
||||
}
|
||||
is_closed_ = true;
|
||||
UnblockPausedWriter();
|
||||
}
|
||||
CloseIo();
|
||||
|
||||
@@ -130,6 +130,7 @@ class BaseEndpointChannel : public EndpointChannel {
|
||||
ConditionVariable is_paused_cond_{&is_paused_mutex_};
|
||||
// If true, writes should block until this has been set to false.
|
||||
bool is_paused_ ABSL_GUARDED_BY(is_paused_mutex_) = false;
|
||||
bool is_closed_ ABSL_GUARDED_BY(is_paused_mutex_) = false;
|
||||
|
||||
// The medium technology information of this endpoint channel.
|
||||
location::nearby::proto::connections::ConnectionTechnology technology_;
|
||||
|
||||
Reference in New Issue
Block a user