You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2022/02/17 00:16:14 UTC

[trafficserver] 03/03: Fix plugin parent_select missing hostname len (#8649)

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

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

commit 4d4dbdbc20f14e1a160dc991a8eea44440b590ef
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Mon Feb 14 12:58:08 2022 -0700

    Fix plugin parent_select missing hostname len (#8649)
    
    (cherry picked from commit a5543613d05a7c17c466d08368f627696d88f8c4)
---
 plugins/experimental/parent_select/consistenthash.cc | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/plugins/experimental/parent_select/consistenthash.cc b/plugins/experimental/parent_select/consistenthash.cc
index dfa1728..762b903 100644
--- a/plugins/experimental/parent_select/consistenthash.cc
+++ b/plugins/experimental/parent_select/consistenthash.cc
@@ -547,9 +547,10 @@ PLNextHopConsistentHash::next(TSHttpTxn txnp, void *strategyTxn, const char *exc
   // ----------------------------------------------------------------------------------------------------
 
   if (pRec && host_stat == TS_HOST_STATUS_UP && (pRec->available.load() || state->retry)) {
-    state->result      = PL_NH_PARENT_SPECIFIED;
-    state->hostname    = pRec->hostname.c_str();
-    state->last_parent = pRec->host_index;
+    state->result       = PL_NH_PARENT_SPECIFIED;
+    state->hostname     = pRec->hostname.c_str();
+    state->hostname_len = pRec->hostname.size();
+    state->last_parent  = pRec->host_index;
     state->last_lookup = state->last_group = cur_ring;
     switch (scheme) {
     case PL_NH_SCHEME_NONE:
@@ -571,11 +572,12 @@ PLNextHopConsistentHash::next(TSHttpTxn txnp, void *strategyTxn, const char *exc
     PL_NH_Debug(PL_NH_DEBUG_TAG, "[%" PRIu64 "] state->result: %s Chosen parent: %s.%d", sm_id, PLNHParentResultStr[state->result],
                 state->hostname, state->port);
   } else {
-    state->result   = go_direct ? PL_NH_PARENT_DIRECT : PL_NH_PARENT_FAIL;
-    state->retry    = false;
-    state->hostname = nullptr;
-    state->port     = 0;
-    state->no_cache = false;
+    state->result       = go_direct ? PL_NH_PARENT_DIRECT : PL_NH_PARENT_FAIL;
+    state->retry        = false;
+    state->hostname     = nullptr;
+    state->hostname_len = 0;
+    state->port         = 0;
+    state->no_cache     = false;
     PL_NH_Debug(PL_NH_DEBUG_TAG, "[%" PRIu64 "] state->result: %s set hostname null port 0 retry %d", sm_id,
                 PLNHParentResultStr[state->result], state->retry);
   }