From: Kefu Chai Date: Wed, 24 Feb 2021 04:43:52 +0000 (+0800) Subject: async/Stack: pass Worker* to NetworkStack::add_thread() X-Git-Tag: v16.2.15~8^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96ab1ec23256d144d8e3fd8723def80a84ca09d4;p=ceph.git async/Stack: pass Worker* to NetworkStack::add_thread() so we don't need to pass worker id to it. Signed-off-by: Kefu Chai (cherry picked from commit 2d6988feabd8759fc77088b0e0e49cbf8c360602) --- diff --git a/src/msg/async/Stack.cc b/src/msg/async/Stack.cc index 37e15634d79c..177a7148cff9 100644 --- a/src/msg/async/Stack.cc +++ b/src/msg/async/Stack.cc @@ -34,9 +34,8 @@ #undef dout_prefix #define dout_prefix *_dout << "stack " -std::function NetworkStack::add_thread(unsigned worker_id) +std::function NetworkStack::add_thread(Worker* w) { - Worker *w = workers[worker_id]; return [this, w]() { char tp_name[16]; sprintf(tp_name, "msgr-worker-%u", w->id); @@ -122,10 +121,10 @@ void NetworkStack::start() } for (unsigned i = 0; i < num_workers; ++i) { - if (workers[i]->is_init()) + Worker* worker = workers[i]; + if (worker->is_init()) continue; - std::function thread = add_thread(i); - spawn_worker(i, std::move(thread)); + spawn_worker(add_thread(worker)); } started = true; lk.unlock(); diff --git a/src/msg/async/Stack.h b/src/msg/async/Stack.h index 6a2188b5a9c7..c5114ce37d0e 100644 --- a/src/msg/async/Stack.h +++ b/src/msg/async/Stack.h @@ -297,7 +297,7 @@ class NetworkStack { ceph::spinlock pool_spin; bool started = false; - std::function add_thread(unsigned i); + std::function add_thread(Worker* w); virtual Worker* create_worker(CephContext *c, unsigned i) = 0;