From b0c20f93abc1e979dbf073f0cce87e5b12d2c512 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Thu, 22 Sep 2016 23:15:58 +0800 Subject: [PATCH] msg/async: avoid set out of range ms_async_op_threads option Signed-off-by: Haomai Wang --- src/msg/async/Event.h | 6 ++++-- src/msg/async/Stack.cc | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/msg/async/Event.h b/src/msg/async/Event.h index eb3397623c25..925425ae121e 100644 --- a/src/msg/async/Event.h +++ b/src/msg/async/Event.h @@ -84,11 +84,13 @@ class EventDriver { * EventCenter maintain a set of file descriptor and handle registered events. */ class EventCenter { - - using clock_type = ceph::coarse_mono_clock; + public: // should be enough; static const int MAX_EVENTCENTER = 24; + private: + using clock_type = ceph::coarse_mono_clock; + struct AssociatedCenters { EventCenter *centers[MAX_EVENTCENTER]; AssociatedCenters(CephContext *c) { diff --git a/src/msg/async/Stack.cc b/src/msg/async/Stack.cc index 25e1d5862f1a..846244389505 100644 --- a/src/msg/async/Stack.cc +++ b/src/msg/async/Stack.cc @@ -69,6 +69,14 @@ NetworkStack::NetworkStack(CephContext *c, const string &t): type(t), started(fa { const uint64_t InitEventNumber = 5000; num_workers = cct->_conf->ms_async_op_threads; + if (num_workers >= EventCenter::MAX_EVENTCENTER) { + ldout(cct, 0) << __func__ << " max thread limit is " + << EventCenter::MAX_EVENTCENTER << ", switching to this now. " + << "Higher thread values are unnecessary and currently unsupported." + << dendl; + num_workers = EventCenter::MAX_EVENTCENTER; + } + for (unsigned i = 0; i < num_workers; ++i) { Worker *w = create_worker(cct, type, i); w->center.init(InitEventNumber, i); -- 2.47.3