mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Fix the bug that the multiplex socket is not closed properly.
PiperOrigin-RevId: 633675141
This commit is contained in:
@@ -254,7 +254,7 @@ void MultiplexOutputStream::MultiplexWriter::StartWriting() {
|
||||
}
|
||||
{
|
||||
MutexLock lock(&writing_mutex_);
|
||||
if (data_queue_.Empty() && is_writing_) {
|
||||
if (data_queue_.Empty() && is_writing_ && !is_closed_) {
|
||||
is_writing_ = false;
|
||||
NEARBY_LOGS(INFO) << TAG << "Waiting for data_queue_ has data.";
|
||||
Exception wait_succeeded = is_writing_cond_.Wait();
|
||||
@@ -264,8 +264,8 @@ void MultiplexOutputStream::MultiplexWriter::StartWriting() {
|
||||
<< ": Failure waiting to wait: " << wait_succeeded.value;
|
||||
return;
|
||||
}
|
||||
if (is_closed_) break;
|
||||
}
|
||||
if (is_closed_) break;
|
||||
}
|
||||
}
|
||||
NEARBY_LOGS(INFO) << TAG << "Writing loop stopped.";
|
||||
|
||||
@@ -438,8 +438,8 @@ void MultiplexSocket::HandleControlFrame(
|
||||
const MultiplexControlFrame& frame) {
|
||||
switch (frame.control_frame_type()) {
|
||||
case MultiplexControlFrame::CONNECTION_REQUEST:
|
||||
RunOffloadThread("CONNECTION_REQUEST", [this, &salted_service_id_hash,
|
||||
&service_id_hash_salt] {
|
||||
RunOffloadThread("CONNECTION_REQUEST", [this, salted_service_id_hash,
|
||||
service_id_hash_salt] {
|
||||
HandleConnectionRequest(salted_service_id_hash, service_id_hash_salt);
|
||||
});
|
||||
break;
|
||||
@@ -451,15 +451,15 @@ void MultiplexSocket::HandleControlFrame(
|
||||
<< ", ConnectionResponseCode: "
|
||||
<< frame.connection_response_frame().connection_response_code();
|
||||
|
||||
RunOffloadThread("CONNECTION_RESPONSE", [this, &salted_service_id_hash,
|
||||
&service_id_hash_salt,
|
||||
RunOffloadThread("CONNECTION_RESPONSE", [this, salted_service_id_hash,
|
||||
service_id_hash_salt,
|
||||
frame = frame] {
|
||||
HandleConnectionResponse(salted_service_id_hash, service_id_hash_salt,
|
||||
frame.connection_response_frame());
|
||||
});
|
||||
break;
|
||||
case MultiplexControlFrame::DISCONNECTION:
|
||||
RunOffloadThread("DISCONNECTION", [this, &salted_service_id_hash] {
|
||||
RunOffloadThread("DISCONNECTION", [this, salted_service_id_hash] {
|
||||
HandleDisconnection(salted_service_id_hash);
|
||||
});
|
||||
break;
|
||||
@@ -642,7 +642,7 @@ void MultiplexSocket::OnPhysicalSocketClosed() {
|
||||
}
|
||||
|
||||
void MultiplexSocket::OnVirtualSocketClosed(const std::string& service_id) {
|
||||
RunOffloadThread("VirtualSocketClosed", [this, &service_id]() {
|
||||
RunOffloadThread("VirtualSocketClosed", [this, service_id]() {
|
||||
{
|
||||
MutexLock lock(&virtual_socket_mutex_);
|
||||
MediumSocket* virtual_socket = GetVirtualSocket(service_id);
|
||||
|
||||
Reference in New Issue
Block a user