From a6a561af47ca7bcca7c277d643aeabb369a813f6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 23 Aug 2017 20:10:23 +0900 Subject: [PATCH] Fix bug that timing script stalls with -m1 --- src/h2load.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/h2load.cc b/src/h2load.cc index 258f3ede..37319f7a 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -309,8 +309,7 @@ void conn_timeout_cb(EV_P_ ev_timer *w, int revents) { namespace { bool check_stop_client_request_timeout(Client *client, ev_timer *w) { - if (client->req_left == 0 || - client->streams.size() >= client->session->max_concurrent_streams()) { + if (client->req_left == 0) { // no more requests to make, stop timer ev_timer_stop(client->worker->loop, w); return true; @@ -324,6 +323,11 @@ namespace { void client_request_timeout_cb(struct ev_loop *loop, ev_timer *w, int revents) { auto client = static_cast(w->data); + if (client->streams.size() >= (size_t)config.max_concurrent_streams) { + ev_timer_stop(client->worker->loop, w); + return; + } + if (client->submit_request() != 0) { ev_timer_stop(client->worker->loop, w); client->process_request_failure(); @@ -833,10 +837,14 @@ void Client::on_stream_close(int32_t stream_id, bool success, bool final) { return; } - if (!config.timing_script && !final && req_left > 0 && - submit_request() != 0) { - process_request_failure(); - return; + if (!final && req_left > 0) { + if (config.timing_script) { + if (!ev_is_active(&request_timeout_watcher)) { + ev_feed_event(worker->loop, &request_timeout_watcher, EV_TIMER); + } + } else if (submit_request() != 0) { + process_request_failure(); + } } }