[COMMIT seastar master] rpc: Wait for server socket to stop before killing conns

0 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
May 29, 2023, 5:28:30 AM5/29/23
to seastar-dev@googlegroups.com, Pavel Emelyanov
From: Pavel Emelyanov <xe...@scylladb.com>
Committer: Pavel Emelyanov <xe...@scylladb.com>
Branch: master

rpc: Wait for server socket to stop before killing conns

After _ss.abort_accept() is called two futures are spawned in parallel
-- wait for the accepting fiber to exit and connections stopping in
parallel. It looks racy, while iterating over connections list accepting
socket may still have chance to push more stuff into it through it still
active continuations.

The fix is in waiting for the accepting fiber _before_ stopping the
connections.

Formatting is deliberately left broken for the ease of review.

Signed-off-by: Pavel Emelyanov <xe...@scylladb.com>

---
diff --git a/src/rpc/rpc.cc b/src/rpc/rpc.cc
--- a/src/rpc/rpc.cc
+++ b/src/rpc/rpc.cc
@@ -1176,12 +1176,14 @@ future<> server::connection::send_unknown_verb_reply(std::optional<rpc_clock_typ
if (_options.streaming_domain) {
_servers.erase(*_options.streaming_domain);
}
- return when_all(_ss_stopped.get_future(),
+ return _ss_stopped.get_future().then([this] {
+ return when_all(
parallel_for_each(_conns | boost::adaptors::map_values, [] (shared_ptr<connection> conn) {
return conn->stop();
}),
_reply_gate.close()
).discard_result();
+ });
}

void server::abort_connection(connection_id id) {
Reply all
Reply to author
Forward
0 new messages