]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notify: process_queue() constructs wait tokens when spawning
authorCasey Bodley <cbodley@redhat.com>
Thu, 15 Aug 2024 17:58:30 +0000 (13:58 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 15 Aug 2024 18:04:49 +0000 (14:04 -0400)
process_queue() spawns several coroutines, then waits on a tokens_waiter
until all of them complete

but spawned coroutines don't start immediately. if we call
waiter.async_wait() before any of the coroutine functions get spawned,
it will find `pending_tokens == 0` and return immediately

instead of constructing each token inside the spawned coroutine
function, construct them outside of spawn and capture them in the lambda
to extend their lifetime until the coroutine's completion

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_notify.cc

index 6b1dd9651f03c4e2fa688d969495eba7676cf40b..3f576120a8ca8cde4de9cdd884426fcaf6445bc3 100644 (file)
@@ -472,11 +472,10 @@ private:
         entries_persistency_tracker& notifs_persistency_tracker = topics_persistency_tracker[queue_name];
         boost::asio::spawn(yield, std::allocator_arg, make_stack_allocator(),
           [this, &notifs_persistency_tracker, &queue_name, entry_idx,
-           total_entries, &end_marker, &remove_entries, &has_error, &waiter,
-           &entry, &needs_migration_vector,
+           total_entries, &end_marker, &remove_entries, &has_error,
+           token = waiter.make_token(), &entry, &needs_migration_vector,
            push_endpoint = push_endpoint.get(),
            &topic_info](boost::asio::yield_context yield) {
-            const auto token = waiter.make_token();
             auto& persistency_tracker = notifs_persistency_tracker[entry.marker];
             auto result =
                 process_entry(this->get_cct()->_conf, persistency_tracker,