From 4de793f20248d926e36b62392c5175349e36038e Mon Sep 17 00:00:00 2001 From: Yang Liming Date: Mon, 13 Oct 2025 10:49:49 +0800 Subject: [PATCH] rdma polling mode all messages run in new bthreads --- src/brpc/input_messenger.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/brpc/input_messenger.cpp b/src/brpc/input_messenger.cpp index 1feb287d65..45ececbc66 100644 --- a/src/brpc/input_messenger.cpp +++ b/src/brpc/input_messenger.cpp @@ -331,12 +331,7 @@ int InputMessenger::ProcessNewMessage( "destroyed when authentication failed"; } } -#if BRPC_WITH_RDMA - if (!m->is_read_progressive() && !rdma::FLAGS_rdma_use_polling) -#else - if (!m->is_read_progressive()) -#endif - { + if (!m->is_read_progressive()) { // Transfer ownership to last_msg last_msg.reset(msg.release()); } else { @@ -346,6 +341,16 @@ int InputMessenger::ProcessNewMessage( num_bthread_created = 0; } } +#if BRPC_WITH_RDMA + // In RDMA polling mode, all messages must be executed in a new bthread and + // not in the bthread where the polling bthread is located, because the + // method for processing messages may call synchronization primitives, + // causing the polling bthread to be scheduled out. + if (rdma::FLAGS_rdma_use_polling) { + QueueMessage(last_msg.release(), &num_bthread_created, + m->_keytable_pool); + } +#endif if (num_bthread_created) { bthread_flush(); }