You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by vm...@apache.org on 2019/04/25 02:10:43 UTC

[trafficserver] branch 7.1.x updated: Revert TS-374 to avoid deadlocks

This is an automated email from the ASF dual-hosted git repository.

vmamidi pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
     new 69d1f7e  Revert TS-374 to avoid deadlocks
69d1f7e is described below

commit 69d1f7e410db637c09bc9749796aff8053df2191
Author: Vijay Mamidi <vi...@yahoo.com>
AuthorDate: Thu Apr 25 06:52:01 2019 +0800

    Revert TS-374 to avoid deadlocks
---
 iocore/hostdb/HostDB.cc | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 6dd2f87..5a17255 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -816,20 +816,22 @@ HostDBProcessor::getbyname_imm(Continuation *cont, process_hostdb_info_pfn proce
       loop = false; // loop only on explicit set for retry
       // find the partition lock
       ProxyMutex *bucket_mutex = hostDB.refcountcache->lock_for_key(md5.hash.fold());
-      SCOPED_MUTEX_LOCK(lock, bucket_mutex, thread);
-      // do a level 1 probe for immediate result.
-      Ptr<HostDBInfo> r = probe(bucket_mutex, md5, false);
-      if (r) {
-        if (r->is_failed()) // fail, see if we should retry with alternate
-          loop = check_for_retry(md5.db_mark, opt.host_res_style);
-        if (!loop) {
-          // No retry -> final result. Return it.
-          Debug("hostdb", "immediate answer for %.*s", md5.host_len, md5.host_name);
-          HOSTDB_INCREMENT_DYN_STAT(hostdb_total_hits_stat);
-          (cont->*process_hostdb_info)(r.get());
-          return ACTION_RESULT_DONE;
+      MUTEX_TRY_LOCK(lock, bucket_mutex, thread);
+      if (lock.is_locked()) {
+        // do a level 1 probe for immediate result.
+        Ptr<HostDBInfo> r = probe(bucket_mutex, md5, false);
+        if (r) {
+          if (r->is_failed()) // fail, see if we should retry with alternate
+            loop = check_for_retry(md5.db_mark, opt.host_res_style);
+          if (!loop) {
+            // No retry -> final result. Return it.
+            Debug("hostdb", "immediate answer for %.*s", md5.host_len, md5.host_name);
+            HOSTDB_INCREMENT_DYN_STAT(hostdb_total_hits_stat);
+            (cont->*process_hostdb_info)(r.get());
+            return ACTION_RESULT_DONE;
+          }
+          md5.refresh(); // Update for retry.
         }
-        md5.refresh(); // Update for retry.
       }
     } while (loop);
   }