From: Kefu Chai Date: Sat, 27 Dec 2014 05:44:24 +0000 (+0800) Subject: AsyncMessenger: should retry in case of EINTR X-Git-Tag: v0.92~78^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c9da51de48e7c5d7e9ed4f4fcd7a7d9da6728c20;p=ceph.git 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 --- diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index ef5d04597179..b99adf6c2e43 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