]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: is_queued() to check if there's any pending writes
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 7 Aug 2019 14:36:28 +0000 (22:36 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Mon, 12 Aug 2019 09:02:51 +0000 (17:02 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/Protocol.cc
src/crimson/net/Protocol.h

index 65bfe2d1b790ccfe1b214beb96e08aab5a84d79c..4e53c7bfbdcd2c76f380b8891bb89e8b7492f313 100644 (file)
@@ -100,7 +100,7 @@ seastar::future<stop_t> Protocol::do_write_dispatch_sweep()
    case write_state_t::open: {
     size_t num_msgs = conn.out_q.size();
     // we must have something to write...
-    ceph_assert(num_msgs || need_keepalive || keepalive_ack.has_value());
+    ceph_assert(is_queued());
     MessageRef front_msg;
     if (likely(num_msgs)) {
       front_msg = conn.out_q.front();
@@ -118,10 +118,10 @@ seastar::future<stop_t> Protocol::do_write_dispatch_sweep()
         // and the out_q was not reset during socket write
         conn.out_q.erase(conn.out_q.begin(), conn.out_q.begin()+num_msgs);
       }
-      if (conn.out_q.empty() && !keepalive_ack.has_value()) {
+      if (!is_queued()) {
         // good, we have nothing pending to send now.
         return socket->flush().then([this] {
-          if (conn.out_q.empty() && !need_keepalive && !keepalive_ack.has_value()) {
+          if (!is_queued()) {
             // still nothing pending to send after flush,
             // the dispatching can ONLY stop now
             ceph_assert(write_dispatching);
index c65ddc7e6a138481ac7d270402b85fb379df4117..fe3598f19d46f978c78ee31bea1ac2c4ed978917 100644 (file)
@@ -84,6 +84,12 @@ class Protocol {
 
   void notify_keepalive_ack(utime_t keepalive_ack);
 
+  bool is_queued() const {
+    return (!conn.out_q.empty() ||
+            need_keepalive ||
+            keepalive_ack.has_value());
+  }
+
  private:
   write_state_t write_state = write_state_t::none;
   // wait until current state changed