]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async: fix is_queued() semantics
authorIlya Dryomov <idryomov@gmail.com>
Fri, 19 Oct 2018 17:34:19 +0000 (19:34 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 19 Oct 2018 18:25:12 +0000 (20:25 +0200)
Before AsyncConnection was split into two classes as part of the
multi-protocol refactor, we only had AsyncConnection::is_queued().
It checked both out_q and outcoming_bl because out_q was part of
AsyncConnection.

out_q is now part of ProtocolV1.  AsyncConnection should no longer be
concerned with out_q, only with outcoming_bl.  Checking whether out_q
is empty in _try_send() is particuarly wrong because if the write is
fininished (i.e. outcoming_bl is empty) but out_q has something in it,
the write callback isn't invoked.

Although probably not strictly necessary, this commit preserves the
semantics of connection->is_queued() in Protocol.cc.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/msg/async/AsyncConnection.cc
src/msg/async/Protocol.cc

index 77f4a9b147b3d28ea91337ef78b125f964e0c126..5bc5c69fad96737a007a5525bde14c77dedf023d 100644 (file)
@@ -551,7 +551,7 @@ void AsyncConnection::_stop() {
 }
 
 bool AsyncConnection::is_queued() const {
-  return protocol->is_queued() || outcoming_bl.length();
+  return outcoming_bl.length();
 }
 
 void AsyncConnection::shutdown_socket() {
index 9f8509eeca6562e4c7b2c401760ea165005b11ca..04c93c6ba8f35046562c3c3643a55272f264ec56 100644 (file)
@@ -367,7 +367,7 @@ void ProtocolV1::write_event() {
         ack_left -= left;
         left = ack_left;
         r = connection->_try_send(left);
-      } else if (connection->is_queued()) {
+      } else if (is_queued()) {
         r = connection->_try_send();
       }
     }
@@ -385,8 +385,7 @@ void ProtocolV1::write_event() {
     connection->write_lock.unlock();
     connection->lock.lock();
     connection->write_lock.lock();
-    if (state == STANDBY && !connection->policy.server &&
-        connection->is_queued()) {
+    if (state == STANDBY && !connection->policy.server && is_queued()) {
       ldout(cct, 10) << __func__ << " policy.server is false" << dendl;
       connection->_connect();
     } else if (connection->cs && state != NONE && state != CLOSED &&
@@ -405,7 +404,9 @@ void ProtocolV1::write_event() {
   }
 }
 
-bool ProtocolV1::is_queued() { return !out_q.empty(); }
+bool ProtocolV1::is_queued() {
+  return !out_q.empty() || connection->is_queued();
+}
 
 void ProtocolV1::run_continuation(CtPtr continuation) {
   CONTINUATION_RUN(continuation);
@@ -453,7 +454,7 @@ CtPtr ProtocolV1::ready() {
 
   connection->write_lock.lock();
   can_write = WriteStatus::CANWRITE;
-  if (connection->is_queued()) {
+  if (is_queued()) {
     connection->center->dispatch_event_external(connection->write_handler);
   }
   connection->write_lock.unlock();