From: Radoslaw Zarzynski Date: Mon, 20 Sep 2021 13:59:30 +0000 (+0000) Subject: crimson/net: fix dangling addrvec in bind(), the repeat_until_value() part. X-Git-Tag: v17.1.0~835^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F43243%2Fhead;p=ceph.git crimson/net: fix dangling addrvec in bind(), the repeat_until_value() part. This is a follow-up to commit 480273082718230d64d2c068db1b22f44997bdc8. `seastar::do_with()` doesn't extend the life-time of the callable's ```cpp auto do_with_impl(T1&& rv1, T2&& rv2, More&&... more) { // ... auto&& just_values = cherry_pick_tuple(idx(), std::move(all)); auto&& just_func = std::move(std::get(std::move(all))); // ... auto task = std::apply( [](auto&&... x) { return std::make_unique>(std::forward(x)...); }, std::move(just_values)); auto fut = std::apply(just_func, task->data()); // ... } ``` closure. This means the `addrs` needs to be captured by value also by the lambda passed to `repeat_until_value()`. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/net/SocketMessenger.cc b/src/crimson/net/SocketMessenger.cc index 13af0434a0f9..8f8ffd8f19ae 100644 --- a/src/crimson/net/SocketMessenger.cc +++ b/src/crimson/net/SocketMessenger.cc @@ -135,7 +135,7 @@ SocketMessenger::bind(const entity_addrvec_t& addrs) using crimson::common::local_conf; return seastar::do_with(int64_t{local_conf()->ms_bind_retry_count}, [this, addrs] (auto& count) { - return seastar::repeat_until_value([this, &addrs, &count] { + return seastar::repeat_until_value([this, addrs, &count] { assert(count >= 0); return try_bind(addrs, local_conf()->ms_bind_port_min,