You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2018/08/13 20:46:07 UTC

[trafficserver] branch master updated: Deal with the case when the hostdb cont may not have a mutex

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

shinrich 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 80bd615  Deal with the case when the hostdb cont may not have a mutex
80bd615 is described below

commit 80bd6150dcba6b676ecb6e66de775602927dafad
Author: Susan Hinrichs <sh...@oath.com>
AuthorDate: Mon Aug 13 16:05:53 2018 +0000

    Deal with the case when the hostdb cont may not have a mutex
---
 iocore/hostdb/HostDB.cc | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index b82b69e..f62cf24 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -1490,20 +1490,32 @@ HostDBContinuation::dnsEvent(int event, HostEnt *e)
         return EVENT_CONT;
       }
 
-      MUTEX_TRY_LOCK_FOR(lock, action.mutex, thread, action.continuation);
       // We have seen cases were the action.mutex != action.continuation.mutex.
       // Since reply_to_cont will call the hanlder on the action.continuation, it is important that we hold
       // that mutex.
-      MUTEX_TRY_LOCK_FOR(lock2, action.continuation->mutex, thread, action.continuation);
-      if (!lock.is_locked() || !lock2.is_locked()) {
+      bool need_to_reschedule = true;
+      MUTEX_TRY_LOCK_FOR(lock, action.mutex, thread, action.continuation);
+      if (lock.is_locked()) {
+        need_to_reschedule = !action.cancelled;
+        if (!action.cancelled) {
+          if (action.continuation->mutex) {
+            MUTEX_TRY_LOCK_FOR(lock2, action.continuation->mutex, thread, action.continuation);
+            if (lock2.is_locked()) {
+              reply_to_cont(action.continuation, r, is_srv());
+              need_to_reschedule = false;
+            }
+          } else {
+            reply_to_cont(action.continuation, r, is_srv());
+            need_to_reschedule = false;
+          }
+        }
+      }
+      if (need_to_reschedule) {
         remove_trigger_pending_dns();
         SET_HANDLER((HostDBContHandler)&HostDBContinuation::probeEvent);
         thread->schedule_in(this, HOST_DB_RETRY_PERIOD);
         return EVENT_CONT;
       }
-      if (!action.cancelled) {
-        reply_to_cont(action.continuation, r, is_srv());
-      }
     }
     // wake up everyone else who is waiting
     remove_trigger_pending_dns();