trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: Cleanup: change RemapPlugins::run_single_remap to return bool.
Date Thu, 06 Dec 2018 22:23:18 GMT
This is an automated email from the ASF dual-hosted git repository.

amc 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 f4fb8fe  Cleanup: change RemapPlugins::run_single_remap to return bool.
f4fb8fe is described below

commit f4fb8fe3e5fd6639f69afbc2db1dd655a5c787d1
Author: Alan M. Carroll <amc@apache.org>
AuthorDate: Fri Nov 30 14:31:27 2018 -0600

    Cleanup: change RemapPlugins::run_single_remap to return bool.
---
 proxy/http/remap/RemapPlugins.cc   | 18 ++++++++----------
 proxy/http/remap/RemapPlugins.h    |  2 +-
 proxy/http/remap/RemapProcessor.cc |  6 ++----
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/proxy/http/remap/RemapPlugins.cc b/proxy/http/remap/RemapPlugins.cc
index cd71cb7..8900e54 100644
--- a/proxy/http/remap/RemapPlugins.cc
+++ b/proxy/http/remap/RemapPlugins.cc
@@ -78,13 +78,13 @@ RemapPlugins::run_plugin(remap_plugin_info *plugin)
     there actually *is* something to do).
 
 */
-int
+bool
 RemapPlugins::run_single_remap()
 {
   url_mapping *map             = _s->url_map.getMapping();
   remap_plugin_info *plugin    = map->get_plugin(_cur); // get the nth plugin in our list
of plugins
   TSRemapStatus plugin_retcode = TSREMAP_NO_REMAP;
-  int zret                     = 1;
+  bool zret                    = true; // default - last iteration.
   Debug("url_rewrite", "running single remap rule id %d for the %d%s time", map->map_id,
_cur,
         _cur == 1 ? "st" : _cur == 2 ? "nd" : _cur == 3 ? "rd" : "th");
 
@@ -108,7 +108,7 @@ RemapPlugins::run_single_remap()
       Debug("url_rewrite", "completed all remap plugins for rule id %d, changed by %d plugins",
map->map_id, _rewritten);
     } else {
       Debug("url_rewrite", "completed single remap, attempting another via immediate callback");
-      zret = 0; // not done yet.
+      zret = false; // not done yet.
     }
 
     // If the chain is finished, and the URL hasn't been rewritten, do the rule remap.
@@ -128,8 +128,6 @@ RemapPlugins::run_remap(int event, Event *e)
   ink_assert(action.continuation);
   ink_assert(action.continuation);
 
-  int ret = 0;
-
   /* make sure we weren't cancelled */
   if (action.cancelled) {
     mutex.clear();
@@ -140,14 +138,14 @@ RemapPlugins::run_remap(int event, Event *e)
   switch (event) {
   case EVENT_IMMEDIATE:
     Debug("url_rewrite", "handling immediate event inside RemapPlugins::run_remap");
-    ret = run_single_remap();
     /**
-     * If ret !=0 then we are done with this processor and we call back into the SM;
-     * otherwise, we call this function again immediately (which really isn't immediate)
-     * thru the eventProcessor, thus forcing another run of run_single_remap() which will
+     * If @c run_single_remap returns @c true then we are done with this processor and we
call back
+     * into the SM; otherwise, we call this function again immediately (which really isn't
+     * immediate) thru the eventProcessor, thus forcing another run of run_single_remap()
which will
      * then operate on _request_url, etc performing additional remaps (mainly another plugin
run)
+     *
      **/
-    if (ret) {
+    if (run_single_remap()) {
       action.continuation->handleEvent(EVENT_REMAP_COMPLETE, nullptr);
       mutex.clear();
       action.mutex.clear();
diff --git a/proxy/http/remap/RemapPlugins.h b/proxy/http/remap/RemapPlugins.h
index fad4097..eafff41 100644
--- a/proxy/http/remap/RemapPlugins.h
+++ b/proxy/http/remap/RemapPlugins.h
@@ -67,7 +67,7 @@ struct RemapPlugins : public Continuation {
   }
 
   int run_remap(int event, Event *e);
-  int run_single_remap();
+  bool run_single_remap();
   TSRemapStatus run_plugin(remap_plugin_info *plugin);
 
   Action action;
diff --git a/proxy/http/remap/RemapProcessor.cc b/proxy/http/remap/RemapProcessor.cc
index e22b710..b8776df 100644
--- a/proxy/http/remap/RemapProcessor.cc
+++ b/proxy/http/remap/RemapProcessor.cc
@@ -318,11 +318,9 @@ RemapProcessor::perform_remap(Continuation *cont, HttpTransact::State
*s)
     return &plugins->action;
   } else {
     RemapPlugins plugins(s, request_url, request_header, hh_info);
-    int ret = 0;
 
-    do {
-      ret = plugins.run_single_remap();
-    } while (ret == 0);
+    while (!plugins.run_single_remap())
+      ; // EMPTY
 
     return ACTION_RESULT_DONE;
   }


Mime
View raw message