Revert "generic_server: use async function in for_each_gently()"

This reverts commit 324b3c43c0.

It isn't safe to do asynchronous calls in `for_each_gently`, as the
connection may be disconnected while a call in callback preempts.

Fixes scylladb/scylla#21801
This commit is contained in:
Michał Jadwiszczak
2024-12-03 11:09:55 +01:00
parent 38a697d064
commit fe67efda5b
3 changed files with 7 additions and 9 deletions

View File

@@ -38,12 +38,13 @@ connection::~connection()
_server._connections_list.erase(iter);
}
future<> server::for_each_gently(noncopyable_function<future<>(connection&)> fn) {
future<> server::for_each_gently(noncopyable_function<void(connection&)> fn) {
_gentle_iterators.emplace_front(*this);
std::list<gentle_iterator>::iterator gi = _gentle_iterators.begin();
return seastar::do_until([ gi ] { return gi->iter == gi->end; },
[ gi, fn = std::move(fn) ] {
return fn(*(gi->iter++));
fn(*(gi->iter++));
return make_ready_future<>();
}
).finally([ this, gi ] { _gentle_iterators.erase(gi); });
}