From e56277fbbb3507903c78dab144847cd68de3cba1 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Mon, 14 Jan 2019 10:43:05 +0800 Subject: [PATCH] crimson/net: fix potential parallel write in SocketConnection All the write/flush in SocketConnection should be serialized, or nasty segment-fault could happen in seastar which is hard to diagnose. This fix serializes the writes in `handle_keepalive2()` with other writes in the open state. Signed-off-by: Yingxin Cheng --- src/crimson/net/SocketConnection.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 0d3d1181fa0..745348f91f2 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -551,8 +551,12 @@ SocketConnection::handle_keepalive2() return socket->read_exactly(sizeof(ceph_timespec)) .then([this] (auto buf) { k.ack.stamp = *reinterpret_cast(buf.get()); - logger().info("{} keepalive2 {}", *this, k.ack.stamp.tv_sec); - return socket->write_flush(make_static_packet(k.ack)); + seastar::shared_future<> f = send_ready.then([this] { + logger().info("{} keepalive2 {}", *this, k.ack.stamp.tv_sec); + return socket->write_flush(make_static_packet(k.ack)); + }); + send_ready = f.get_future(); + return f.get_future(); }); } -- 2.39.5