mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36: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_);
|
MutexLock lock(&writing_mutex_);
|
||||||
if (data_queue_.Empty() && is_writing_) {
|
if (data_queue_.Empty() && is_writing_ && !is_closed_) {
|
||||||
is_writing_ = false;
|
is_writing_ = false;
|
||||||
NEARBY_LOGS(INFO) << TAG << "Waiting for data_queue_ has data.";
|
NEARBY_LOGS(INFO) << TAG << "Waiting for data_queue_ has data.";
|
||||||
Exception wait_succeeded = is_writing_cond_.Wait();
|
Exception wait_succeeded = is_writing_cond_.Wait();
|
||||||
@@ -264,8 +264,8 @@ void MultiplexOutputStream::MultiplexWriter::StartWriting() {
|
|||||||
<< ": Failure waiting to wait: " << wait_succeeded.value;
|
<< ": Failure waiting to wait: " << wait_succeeded.value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_closed_) break;
|
|
||||||
}
|
}
|
||||||
|
if (is_closed_) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NEARBY_LOGS(INFO) << TAG << "Writing loop stopped.";
|
NEARBY_LOGS(INFO) << TAG << "Writing loop stopped.";
|
||||||
|
|||||||
@@ -438,8 +438,8 @@ void MultiplexSocket::HandleControlFrame(
|
|||||||
const MultiplexControlFrame& frame) {
|
const MultiplexControlFrame& frame) {
|
||||||
switch (frame.control_frame_type()) {
|
switch (frame.control_frame_type()) {
|
||||||
case MultiplexControlFrame::CONNECTION_REQUEST:
|
case MultiplexControlFrame::CONNECTION_REQUEST:
|
||||||
RunOffloadThread("CONNECTION_REQUEST", [this, &salted_service_id_hash,
|
RunOffloadThread("CONNECTION_REQUEST", [this, salted_service_id_hash,
|
||||||
&service_id_hash_salt] {
|
service_id_hash_salt] {
|
||||||
HandleConnectionRequest(salted_service_id_hash, service_id_hash_salt);
|
HandleConnectionRequest(salted_service_id_hash, service_id_hash_salt);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -451,15 +451,15 @@ void MultiplexSocket::HandleControlFrame(
|
|||||||
<< ", ConnectionResponseCode: "
|
<< ", ConnectionResponseCode: "
|
||||||
<< frame.connection_response_frame().connection_response_code();
|
<< frame.connection_response_frame().connection_response_code();
|
||||||
|
|
||||||
RunOffloadThread("CONNECTION_RESPONSE", [this, &salted_service_id_hash,
|
RunOffloadThread("CONNECTION_RESPONSE", [this, salted_service_id_hash,
|
||||||
&service_id_hash_salt,
|
service_id_hash_salt,
|
||||||
frame = frame] {
|
frame = frame] {
|
||||||
HandleConnectionResponse(salted_service_id_hash, service_id_hash_salt,
|
HandleConnectionResponse(salted_service_id_hash, service_id_hash_salt,
|
||||||
frame.connection_response_frame());
|
frame.connection_response_frame());
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case MultiplexControlFrame::DISCONNECTION:
|
case MultiplexControlFrame::DISCONNECTION:
|
||||||
RunOffloadThread("DISCONNECTION", [this, &salted_service_id_hash] {
|
RunOffloadThread("DISCONNECTION", [this, salted_service_id_hash] {
|
||||||
HandleDisconnection(salted_service_id_hash);
|
HandleDisconnection(salted_service_id_hash);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -642,7 +642,7 @@ void MultiplexSocket::OnPhysicalSocketClosed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MultiplexSocket::OnVirtualSocketClosed(const std::string& service_id) {
|
void MultiplexSocket::OnVirtualSocketClosed(const std::string& service_id) {
|
||||||
RunOffloadThread("VirtualSocketClosed", [this, &service_id]() {
|
RunOffloadThread("VirtualSocketClosed", [this, service_id]() {
|
||||||
{
|
{
|
||||||
MutexLock lock(&virtual_socket_mutex_);
|
MutexLock lock(&virtual_socket_mutex_);
|
||||||
MediumSocket* virtual_socket = GetVirtualSocket(service_id);
|
MediumSocket* virtual_socket = GetVirtualSocket(service_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user