You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "bneradt (via GitHub)" <gi...@apache.org> on 2023/03/20 15:33:37 UTC

[GitHub] [trafficserver] bneradt commented on a diff in pull request #9539: Change IpMap to IPSpace for IP address based redirect actions.

bneradt commented on code in PR #9539:
URL: https://github.com/apache/trafficserver/pull/9539#discussion_r1142309866


##########
proxy/http/HttpTransact.cc:
##########
@@ -1971,11 +1971,11 @@ HttpTransact::OSDNSLookup(State *s)
       action = s->http_config_param->redirect_actions_self_action;
       TxnDebug("http_trans", "[OSDNSLookup] Self action - %d.", int(action));
     } else {
-      // Make sure the return value from contains is big enough for a void*.
-      intptr_t x{intptr_t(RedirectEnabled::Action::INVALID)};
       ink_release_assert(s->http_config_param->redirect_actions_map != nullptr);
-      ink_release_assert(s->http_config_param->redirect_actions_map->contains(s->dns_info.addr, reinterpret_cast<void **>(&x)));
-      action = static_cast<RedirectEnabled::Action>(x);
+      auto &addrs = *(s->http_config_param->redirect_actions_map);
+      auto spot   = addrs.find(swoc::IPAddr(&s->dns_info.addr.sa));
+      ink_release_assert(spot != addrs.end()); // Should always find an entry.
+      action = std::get<1>(*spot);

Review Comment:
   Can we use a structured binding on find instead of std::get? Something like:
   
   ```cpp
   auto &[key, action] = addrs.find...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org