crimson/net: Fix racing for promise on_message 24097/head
authorYingxin <yingxin.cheng@intel.com>
Fri, 14 Sep 2018 10:21:07 +0000 (18:21 +0800)
committerYingxin <yingxin.cheng@intel.com>
Fri, 14 Sep 2018 10:33:21 +0000 (18:33 +0800)
read_tags_until_next_message() will forward the ready future and create
a new promise for on_message, which assumes there is already a
read_message() holding the previous promise, but it is not true.

Signed-off-by: Yingxin <yingxin.cheng@intel.com>
src/crimson/net/SocketConnection.cc

index 3a9cb1f58345cecdea766a6cbc8fc55d9787806d..2ad467b55d0b820d1f18c27b652a16da9ec60f83 100644 (file)
@@ -161,7 +161,6 @@ void SocketConnection::read_tags_until_next_message()
     }).then_wrapped([this] (auto fut) {
       // satisfy the message promise
       fut.forward_to(std::move(on_message));
-      on_message = seastar::promise<>{};
     });
 }
 
@@ -209,6 +208,7 @@ seastar::future<MessageRef> SocketConnection::read_message()
 {
   return on_message.get_future()
     .then([this] {
+      on_message = seastar::promise<>{};
       // read header
       return read(sizeof(m.header));
     }).then([this] (bufferlist bl) {