@@ -226,6 +226,11 @@ class RemapRegex
226226 {
227227 return _lowercase_substitutions;
228228 }
229+ inline bool
230+ has_strategy () const
231+ {
232+ return _has_strategy;
233+ }
229234 inline std::string const &
230235 strategy () const
231236 {
@@ -268,7 +273,8 @@ class RemapRegex
268273 int _connect_timeout = -1 ;
269274 int _dns_timeout = -1 ;
270275
271- std::string _strategy = {};
276+ bool _has_strategy = false ;
277+ std::string _strategy = {};
272278
273279 Override *_first_override = nullptr ;
274280 int _sub_pos[MAX_SUBS];
@@ -317,7 +323,8 @@ RemapRegex::initialize(const std::string ®, const std::string &sub, const std
317323 } else if (opt.compare (start, 23 , " lowercase_substitutions" ) == 0 ) {
318324 _lowercase_substitutions = true ;
319325 } else if (opt.compare (start, 8 , " strategy" ) == 0 ) {
320- _strategy = opt_val;
326+ _has_strategy = true ;
327+ _strategy = opt_val;
321328 } else if (opt_val.size () <= 0 ) {
322329 // All other options have a required value
323330 TSError (" [%s] Malformed options: %s" , PLUGIN_NAME, opt.c_str ());
@@ -980,17 +987,19 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
980987 Dbg (dbg_ctl, " Setting DNS timeout to %d" , re->dns_timeout_option ());
981988 TSHttpTxnDNSTimeoutSet (txnp, re->dns_timeout_option ());
982989 }
983- auto const &strat = re->strategy ();
984- if (strat.empty () || " null" == strat) {
985- Dbg (dbg_ctl, " Clearing strategy (use parent.config)" );
986- TSHttpTxnNextHopStrategySet (txnp, nullptr );
987- } else {
988- void const *const stratptr = TSHttpTxnNextHopNamedStrategyGet (txnp, strat.c_str ());
989- if (nullptr == stratptr) {
990- Dbg (dbg_ctl, " No strategy found with name '%s'" , strat.c_str ());
990+ if (re->has_strategy ()) {
991+ auto const &strat = re->strategy ();
992+ if (strat.empty () || " null" == strat) {
993+ Dbg (dbg_ctl, " Clearing strategy (use parent.config)" );
994+ TSHttpTxnNextHopStrategySet (txnp, nullptr );
991995 } else {
992- Dbg (dbg_ctl, " Setting strategy to %s" , strat.c_str ());
993- TSHttpTxnNextHopStrategySet (txnp, stratptr);
996+ void const *const stratptr = TSHttpTxnNextHopNamedStrategyGet (txnp, strat.c_str ());
997+ if (nullptr == stratptr) {
998+ Dbg (dbg_ctl, " No strategy found with name '%s'" , strat.c_str ());
999+ } else {
1000+ Dbg (dbg_ctl, " Setting strategy to %s" , strat.c_str ());
1001+ TSHttpTxnNextHopStrategySet (txnp, stratptr);
1002+ }
9941003 }
9951004 }
9961005 bool lowercase_substitutions = false ;
0 commit comments