This is an automated email from the ASF dual-hosted git repository. oknet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 34dcdb2 Optimize: Keep cont->mutex locked, during probe the bucket by hash object within HostDBProcessor::getby 34dcdb2 is described below commit 34dcdb278b92b04f2c19f1cd3a48f94c8ae65dfb Author: Oknet Xu <xuc...@skyguard.com.cn> AuthorDate: Sat Feb 2 19:13:33 2019 +0800 Optimize: Keep cont->mutex locked, during probe the bucket by hash object within HostDBProcessor::getby --- iocore/hostdb/HostDB.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index dd80c58..fbf410c 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -634,19 +634,18 @@ HostDBProcessor::getby(Continuation *cont, const char *hostname, int len, sockad // Attempt to find the result in-line, for level 1 hits // if (!aforce_dns) { - bool loop; - do { + MUTEX_TRY_LOCK(lock, cont->mutex, thread); + bool loop = lock.is_locked(); + while (loop) { loop = false; // Only loop on explicit set for retry. // find the partition lock // - // TODO: Could we reuse the "mutex" above safely? I think so but not sure. - Ptr<ProxyMutex> bmutex = hostDB.refcountcache->lock_for_key(hash.hash.fold()); - MUTEX_TRY_LOCK(lock, bmutex, thread); - MUTEX_TRY_LOCK(lock2, cont->mutex, thread); + Ptr<ProxyMutex> bucket_mutex = hostDB.refcountcache->lock_for_key(hash.hash.fold()); + MUTEX_TRY_LOCK(lock2, bucket_mutex, thread); - if (lock.is_locked() && lock2.is_locked()) { + if (lock2.is_locked()) { // If we can get the lock and a level 1 probe succeeds, return - Ptr<HostDBInfo> r = probe(bmutex, hash, aforce_dns); + Ptr<HostDBInfo> r = probe(bucket_mutex, hash, aforce_dns); if (r) { if (r->is_failed() && hostname) { loop = check_for_retry(hash.db_mark, host_res_style); @@ -662,7 +661,7 @@ HostDBProcessor::getby(Continuation *cont, const char *hostname, int len, sockad hash.refresh(); // only on reloop, because we've changed the family. } } - } while (loop); + } } Debug("hostdb", "delaying force %d answer for %s", aforce_dns, hostname ? hostname : ats_is_ip(ip) ? ats_ip_ntop(ip, ipb, sizeof ipb) : "<null>");