From c80f0d7a99309e1636edc15913175bae96c3aaf7 Mon Sep 17 00:00:00 2001 From: wenjunhuang Date: Fri, 3 Jul 2015 13:10:41 +0800 Subject: [PATCH 2/2] Change cond wait to cond_timeout wait in Client::make_request Signed-off-by: wenjunhuang --- src/client/Client.cc | 11 ++++++++--- src/common/config_opts.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 2bc242c..45d632f 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -1544,12 +1544,17 @@ int Client::make_request(MetaRequest *request, request->kick = false; while (!request->reply && // reply request->resend_mds < 0 && // forward - !request->kick) - caller_cond.Wait(client_lock); + !request->kick) { + utime_t w; + w.set_from_double(cct->_conf->client_request_timeout); + int ret_status = caller_cond.WaitInterval(cct, client_lock, w); + if (ret_status == ETIMEDOUT && !request->reply) + request->aborted = true; + } request->caller_cond = NULL; // did we get a reply? - if (request->reply) + if (request->reply) break; } diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 1ea85a6..a7178fd 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -301,6 +301,7 @@ OPTION(mon_pool_quota_crit_threshold, OPT_INT, 0) // percent of quota at which t OPTION(client_cache_size, OPT_INT, 16384) OPTION(client_cache_mid, OPT_FLOAT, .75) OPTION(client_use_random_mds, OPT_BOOL, false) +OPTION(client_request_timeout, OPT_DOUBLE, 120.0) // timeout for a single request to mds in seconds OPTION(client_mount_timeout, OPT_DOUBLE, 300.0) OPTION(client_tick_interval, OPT_DOUBLE, 1.0) OPTION(client_trace, OPT_STR, "") -- 1.9.3