From 3350b3504542196cadfa33d9592cca93463d3d1b Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Thu, 26 Oct 2017 00:34:45 +0800 Subject: [PATCH] msg/async: only system can accept more data, continue send. Signed-off-by: Jianpeng Ma --- src/msg/async/AsyncConnection.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 3f09648d05783..30eec2f3f30a4 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -2412,18 +2412,21 @@ void AsyncConnection::handle_write() } while (can_write == WriteStatus::CANWRITE); write_lock.unlock(); - uint64_t left = ack_left; - if (left) { - ceph_le64 s; - s = in_seq; - outcoming_bl.append(CEPH_MSGR_TAG_ACK); - outcoming_bl.append((char*)&s, sizeof(s)); - ldout(async_msgr->cct, 10) << __func__ << " try send msg ack, acked " << left << " messages" << dendl; - ack_left -= left; - left = ack_left; - r = _try_send(left); - } else if (is_queued()) { - r = _try_send(); + // if r > 0 mean data still lefted, so no need _try_send. + if (r == 0) { + uint64_t left = ack_left; + if (left) { + ceph_le64 s; + s = in_seq; + outcoming_bl.append(CEPH_MSGR_TAG_ACK); + outcoming_bl.append((char*)&s, sizeof(s)); + ldout(async_msgr->cct, 10) << __func__ << " try send msg ack, acked " << left << " messages" << dendl; + ack_left -= left; + left = ack_left; + r = _try_send(left); + } else if (is_queued()) { + r = _try_send(); + } } logger->tinc(l_msgr_running_send_time, ceph::mono_clock::now() - start); -- 2.39.5