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

[trafficserver] branch master updated: Parent Selection -- Host Marking -- Handle pRec == nullptr and wrap-around cases.

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

jrushford 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 41b3121  Parent Selection -- Host Marking -- Handle pRec == nullptr and wrap-around cases.
41b3121 is described below

commit 41b3121f454ef5c317c7f0ccfe2d00c30b36918f
Author: Peter Chou <pb...@labs.att.com>
AuthorDate: Wed May 2 23:28:46 2018 -0700

    Parent Selection -- Host Marking -- Handle pRec == nullptr and wrap-around cases.
    
    * Do not call pStatus.getHostStatus() is pRec == nullptr just set to HOST_STATUS_INIT.
    
    * Add !pRec as valid condition for further searching of parents.
    
    * Changed !prtmp to !pRec to enhance clarity.
    
    * Added requirement that selected parent must be UP prior to populating the
      result structure otherwise an invalid choice may be returned in the case
      of all rings wrapped with no valid results.
---
 proxy/ParentConsistentHash.cc | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/proxy/ParentConsistentHash.cc b/proxy/ParentConsistentHash.cc
index 72ada84..b68f31b 100644
--- a/proxy/ParentConsistentHash.cc
+++ b/proxy/ParentConsistentHash.cc
@@ -169,9 +169,9 @@ ParentConsistentHash::selectParent(bool first_call, ParentResult *result, Reques
       } while (prtmp && strcmp(prtmp->hostname, result->hostname) == 0);
     }
   }
-  host_stat = pStatus.getHostStatus(pRec->hostname);
-  // didn't find a parent or the parent is marked unavailable.
-  if ((pRec && !pRec->available) || host_stat == HOST_STATUS_DOWN) {
+  host_stat = (pRec) ? pStatus.getHostStatus(pRec->hostname) : HostStatus_t::HOST_STATUS_INIT;
+  // didn't find a parent or the parent is marked unavailable or the parent is marked down
+  if (!pRec || (pRec && !pRec->available) || host_stat == HOST_STATUS_DOWN) {
     do {
       // check if the host is retryable.  It's retryable if the retry window has elapsed
       // and the global host status is HOST_STATUS_UP
@@ -221,12 +221,13 @@ ParentConsistentHash::selectParent(bool first_call, ParentResult *result, Reques
         Debug("parent_select", "No available parents.");
         break;
       }
-      host_stat = pStatus.getHostStatus(pRec->hostname);
-    } while (!prtmp || !pRec->available || host_stat == HOST_STATUS_DOWN);
+      host_stat = (pRec) ? pStatus.getHostStatus(pRec->hostname) : HostStatus_t::HOST_STATUS_INIT;
+    } while (!pRec || !pRec->available || host_stat == HOST_STATUS_DOWN);
   }
 
   // use the available or marked for retry parent.
-  if (pRec && (pRec->available || result->retry)) {
+  host_stat = (pRec) ? pStatus.getHostStatus(pRec->hostname) : HostStatus_t::HOST_STATUS_INIT;
+  if (pRec && host_stat == HOST_STATUS_UP && (pRec->available || result->retry)) {
     result->result      = PARENT_SPECIFIED;
     result->hostname    = pRec->hostname;
     result->port        = pRec->port;

-- 
To stop receiving notification emails like this one, please contact
jrushford@apache.org.