From 0d13ef2f2013b201f09d67c86f34253fb86cd736 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Mon, 24 Jun 2019 20:24:36 +0800 Subject: [PATCH] msg/async: add comments for commit 294c41f18adada6ab. Consider this case: send-thread msg-work write_event() r = write_message() connection->write_lock.lock() if (.. && !write_in_progress) { write_in_progress = true; add external_event } connection->write_lock.unlock() connection->write_lock.lock() if (r > 0) break; } while (); write_in_progress = false; For this case, we don't add external_event and in write_event we don't check out_q whether empty rather than break. This make msg-work never wake up again. Fortunately, if write_message() > 0, in AsyncConnection::_try_send will add an EVENT_WRITEABLE to wake up msg-work. So bug can't occur. I add comment to descript this and hope get the better method to fix this. Signed-off-by: Jianpeng Ma --- src/msg/async/ProtocolV1.cc | 7 +++++-- src/msg/async/ProtocolV2.cc | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc index b410a2e6b79e9..1708b0c211e63 100644 --- a/src/msg/async/ProtocolV1.cc +++ b/src/msg/async/ProtocolV1.cc @@ -346,8 +346,11 @@ void ProtocolV1::write_event() { } else if (r < 0) { ldout(cct, 1) << __func__ << " send msg failed" << dendl; break; - } else if (r > 0) - break; + } else if (r > 0) { + // Outbound message in-progress, thread will be re-awoken + // when the outbound socket is writeable again + break; + } } while (can_write == WriteStatus::CANWRITE); write_in_progress = false; connection->write_lock.unlock(); diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 77ab2dfd95559..5eb3cf883dad3 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -626,8 +626,11 @@ void ProtocolV2::write_event() { } else if (r < 0) { ldout(cct, 1) << __func__ << " send msg failed" << dendl; break; - } else if (r > 0) + } else if (r > 0) { + // Outbound message in-progress, thread will be re-awoken + // when the outbound socket is writeable again break; + } } while (can_write); write_in_progress = false; -- 2.39.5