]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: fix dangling addrvec in bind(), the repeat_until_value() part. 43243/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 20 Sep 2021 13:59:30 +0000 (13:59 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 21 Sep 2021 13:57:40 +0000 (13:57 +0000)
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<nr>(std::move(all)));
    // ...
    auto task = std::apply(
        [](auto&&... x) {
            return std::make_unique<internal::do_with_state<value_tuple, ret_type>>(std::forward<decltype(x)>(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 <rzarzyns@redhat.com>
src/crimson/net/SocketMessenger.cc

index 13af0434a0f95a497083db78bc279246cd8ffe7c..8f8ffd8f19ae041006c1db18d97bf759447e67f0 100644 (file)
@@ -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,