From 9cce2381cbeba3409b8d79659a6ba502985afacb Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Tue, 3 Dec 2019 20:16:25 +0200 Subject: [PATCH] rgw/pubsub: prevent kafka thread from spinning when there are no messages Signed-off-by: Yuval Lifshitz --- src/rgw/rgw_kafka.cc | 10 +++++----- src/test/rgw/rgw_multi/tests_ps.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rgw/rgw_kafka.cc b/src/rgw/rgw_kafka.cc index b1b97493305..4f7751ae6c6 100644 --- a/src/rgw/rgw_kafka.cc +++ b/src/rgw/rgw_kafka.cc @@ -372,9 +372,9 @@ private: while (!stopped) { // publish all messages in the queue - auto event_count = 0U; - const auto count = messages.consume_all(std::bind(&Manager::publish_internal, this, std::placeholders::_1)); - dequeued += count; + auto reply_count = 0U; + const auto send_count = messages.consume_all(std::bind(&Manager::publish_internal, this, std::placeholders::_1)); + dequeued += send_count; ConnectionList::iterator conn_it; ConnectionList::const_iterator end_it; { @@ -412,14 +412,14 @@ private: INCREMENT_AND_CONTINUE(conn_it); } - event_count += rd_kafka_poll(conn->producer, read_timeout_ms); + reply_count += rd_kafka_poll(conn->producer, read_timeout_ms); // just increment the iterator ++conn_it; } // if no messages were received or published // across all connection, sleep for 100ms - if (count == 0 && event_count) { + if (send_count == 0 && reply_count == 0) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } diff --git a/src/test/rgw/rgw_multi/tests_ps.py b/src/test/rgw/rgw_multi/tests_ps.py index ebac97d3dce..f490809a5d1 100644 --- a/src/test/rgw/rgw_multi/tests_ps.py +++ b/src/test/rgw/rgw_multi/tests_ps.py @@ -28,7 +28,7 @@ from nose.tools import assert_not_equal, assert_equal # configure logging for the tests module log = logging.getLogger(__name__) -skip_push_tests = False +skip_push_tests = True #################################### # utility functions for pubsub tests