From c9da51de48e7c5d7e9ed4f4fcd7a7d9da6728c20 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 27 Dec 2014 13:44:24 +0800 Subject: [PATCH] AsyncMessenger: should retry in case of EINTR * if EINTR is returned, do_send() should return 0 or `continue`. * reword the comment a little bit Signed-off-by: Kefu Chai --- src/msg/async/AsyncConnection.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index ef5d0459717..b99adf6c2e4 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -238,23 +238,24 @@ int AsyncConnection::do_sendmsg(struct msghdr &msg, int len, bool more) if (r == 0) { ldout(async_msgr->cct, 10) << __func__ << " sendmsg got r==0!" << dendl; } else if (r < 0) { - if (errno == EAGAIN || errno == EINTR) { - r = len; + if (errno == EINTR) { + continue; + } else if (errno == EAGAIN) { + break; } else { ldout(async_msgr->cct, 1) << __func__ << " sendmsg error: " << cpp_strerror(errno) << dendl; + return r; } - - return r; } len -= r; if (len == 0) break; - // hrmph. trim r bytes off the front of our message. + // hrmph. drain r bytes from the front of our message. ldout(async_msgr->cct, 20) << __func__ << " short write did " << r << ", still have " << len << dendl; while (r > 0) { if (msg.msg_iov[0].iov_len <= (size_t)r) { - // lose this whole item + // drain this whole item r -= msg.msg_iov[0].iov_len; msg.msg_iov++; msg.msg_iovlen--; @@ -265,7 +266,7 @@ int AsyncConnection::do_sendmsg(struct msghdr &msg, int len, bool more) } } } - return 0; + return len; } // return the remaining bytes, it may larger than the length of ptr -- 2.47.3