From 979b4cbae8e374132c98e959446e8a58dc6bcebf Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Wed, 5 Feb 2014 17:22:14 -0800 Subject: [PATCH] msg/Pipe: add option to restrict delay injection to specific msg type This makes it possible to test timeouts reliably by delaying certain messages effectively forever, but still being able to e.g. connect and authenticate to the monitors. Signed-off-by: Josh Durgin (cherry picked from commit d389e617c1019e44848330bf9570138ac7b0e5d4) --- src/common/config_opts.h | 1 + src/msg/Pipe.cc | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 0331d849e2627..12c079fdc85d9 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -121,6 +121,7 @@ OPTION(ms_pq_max_tokens_per_priority, OPT_U64, 4194304) OPTION(ms_pq_min_cost, OPT_U64, 65536) OPTION(ms_inject_socket_failures, OPT_U64, 0) OPTION(ms_inject_delay_type, OPT_STR, "") // "osd mds mon client" allowed +OPTION(ms_inject_delay_msg_type, OPT_STR, "") // the type of message to delay, as returned by Message::get_type_name(). This is an additional restriction on the general type filter ms_inject_delay_type. OPTION(ms_inject_delay_max, OPT_DOUBLE, 1) // seconds OPTION(ms_inject_delay_probability, OPT_DOUBLE, 0) // range [0, 1] OPTION(ms_inject_internal_delays, OPT_DOUBLE, 0) // seconds diff --git a/src/msg/Pipe.cc b/src/msg/Pipe.cc index 66b64d0097a0c..cedb2ee95dc61 100644 --- a/src/msg/Pipe.cc +++ b/src/msg/Pipe.cc @@ -193,12 +193,14 @@ void *Pipe::DelayedDelivery::entry() continue; } utime_t release = delay_queue.front().first; - if (release > ceph_clock_now(pipe->msgr->cct)) { + Message *m = delay_queue.front().second; + string delay_msg_type = pipe->msgr->cct->_conf->ms_inject_delay_msg_type; + if (release > ceph_clock_now(pipe->msgr->cct) && + (delay_msg_type.empty() || m->get_type_name() == delay_msg_type)) { lgeneric_subdout(pipe->msgr->cct, ms, 10) << pipe->_pipe_prefix(_dout) << "DelayedDelivery::entry sleeping on delay_cond until " << release << dendl; delay_cond.WaitUntil(delay_lock, release); continue; } - Message *m = delay_queue.front().second; lgeneric_subdout(pipe->msgr->cct, ms, 10) << pipe->_pipe_prefix(_dout) << "DelayedDelivery::entry dequeuing message " << m << " for delivery, past " << release << dendl; delay_queue.pop_front(); pipe->in_q->enqueue(m, m->get_priority(), pipe->conn_id); -- 2.39.5