From: Jianpeng Ma Date: Mon, 24 Jun 2019 12:24:36 +0000 (+0800) Subject: msg/async: add comments for commit 294c41f18adada6ab. X-Git-Tag: v15.1.0~2386^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0d13ef2f2013b201f09d67c86f34253fb86cd736;p=ceph.git 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 --- diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc index b410a2e6b79e..1708b0c211e6 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 77ab2dfd9555..5eb3cf883dad 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;