You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2016/05/02 18:55:53 UTC

[trafficserver] 05/06: TS-4388: Refactor ParentResult initialization.

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

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 2bf1a31cc95a2ffb1404d0a53e37190243c0aa1d
Author: James Peach <jp...@apache.org>
AuthorDate: Fri Apr 29 20:34:56 2016 -0700

    TS-4388: Refactor ParentResult initialization.
    
    There are a couple of placed where ParentResult objects are
    reinitialized. Refactor this into ParentResult::reset() so avoid
    duplicated code.
---
 proxy/ParentSelection.cc |  6 +-----
 proxy/ParentSelection.h  | 15 +++++++++------
 proxy/http/HttpSM.cc     |  2 +-
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 280ac9c..bbedbaf 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -119,11 +119,7 @@ ParentConfigParams::findParent(HttpRequestData *rdata, ParentResult *result)
     return;
   }
   // Initialize the result structure
-  result->rec = NULL;
-  result->line_number = 0xffffffff;
-  result->wrap_around = false;
-  result->start_parent = 0;
-  result->last_parent = 0;
+  result->reset();
 
   // Check to see if the parent was set through the
   //   api
diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h
index 6d8db3b..975b07a 100644
--- a/proxy/ParentSelection.h
+++ b/proxy/ParentSelection.h
@@ -158,18 +158,21 @@ public:
 ParentRecord *const extApiRecord = (ParentRecord *)0xeeeeffff;
 
 struct ParentResult {
-  ParentResult()
-    : result(PARENT_UNDEFINED), hostname(NULL), port(0), retry(false), line_number(0), rec(NULL), last_parent(0), start_parent(0),
-      wrap_around(false), last_lookup(0)
-  {
-  }
-
+  ParentResult() { reset(); }
   // For outside consumption
   ParentResultType result;
   const char *hostname;
   int port;
   bool retry;
 
+  void
+  reset()
+  {
+    ink_zero(*this);
+    line_number = -1;
+    result = PARENT_UNDEFINED;
+  }
+
   // Internal use only
   //   Not to be modified by HTTP
   int line_number;
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index be76c29..9221aa8 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7647,7 +7647,7 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
   // we want to close the server session
   // will do that in handle_api_return under the
   // HttpTransact::SM_ACTION_REDIRECT_READ state
-  t_state.parent_result.result = PARENT_UNDEFINED;
+  t_state.parent_result.reset();
   t_state.request_sent_time = 0;
   t_state.response_received_time = 0;
   t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT;

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.