From 5c0a689d720f1016846ff945ca75b9f91756170d Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Sun, 13 Mar 2016 12:24:35 +0800 Subject: [PATCH] AsyncConnection: remove unnecessary "send" flag Signed-off-by: Haomai Wang --- src/msg/async/AsyncConnection.cc | 9 +++------ src/msg/async/AsyncConnection.h | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index a35f1eaedff0..4d18f93f0181 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -345,11 +345,8 @@ ssize_t AsyncConnection::do_sendmsg(struct msghdr &msg, unsigned len, bool more) // return the remaining bytes, it may larger than the length of ptr // else return < 0 means error -ssize_t AsyncConnection::_try_send(bool send, bool more) +ssize_t AsyncConnection::_try_send(bool more) { - if (!send) - return 0; - if (async_msgr->cct->_conf->ms_inject_socket_failures && sd >= 0) { if (rand() % async_msgr->cct->_conf->ms_inject_socket_failures == 0) { ldout(async_msgr->cct, 0) << __func__ << " injecting socket failure" << dendl; @@ -2378,7 +2375,7 @@ ssize_t AsyncConnection::write_message(Message *m, bufferlist& bl, bool more) logger->inc(l_msgr_send_bytes, outcoming_bl.length() - original_bl_len); ldout(async_msgr->cct, 20) << __func__ << " sending " << m->get_seq() << " " << m << dendl; - ssize_t rc = _try_send(true, more); + ssize_t rc = _try_send(more); if (rc < 0) { ldout(async_msgr->cct, 1) << __func__ << " error sending " << m << ", " << cpp_strerror(errno) << dendl; @@ -2488,7 +2485,7 @@ void AsyncConnection::handle_write() ldout(async_msgr->cct, 10) << __func__ << " try send msg ack, acked " << left << " messages" << dendl; ack_left.sub(left); left = ack_left.read(); - r = _try_send(true, left); + r = _try_send(left); } else if (is_queued()) { r = _try_send(); } diff --git a/src/msg/async/AsyncConnection.h b/src/msg/async/AsyncConnection.h index 4a76a7c1b241..0b71d7fc09e9 100644 --- a/src/msg/async/AsyncConnection.h +++ b/src/msg/async/AsyncConnection.h @@ -51,14 +51,14 @@ class AsyncConnection : public Connection { void suppress_sigpipe(); void restore_sigpipe(); ssize_t do_sendmsg(struct msghdr &msg, unsigned len, bool more); - ssize_t try_send(bufferlist &bl, bool send=true, bool more=false) { + ssize_t try_send(bufferlist &bl, bool more=false) { Mutex::Locker l(write_lock); outcoming_bl.claim_append(bl); - return _try_send(send, more); + return _try_send(more); } // if "send" is false, it will only append bl to send buffer // the main usage is avoid error happen outside messenger threads - ssize_t _try_send(bool send=true, bool more=false); + ssize_t _try_send(bool more=false); ssize_t _send(Message *m); void prepare_send_message(uint64_t features, Message *m, bufferlist &bl); ssize_t read_until(unsigned needed, char *p); -- 2.47.3