You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/05/03 20:53:57 UTC

[GitHub] [trafficserver] SolidWallOfCode opened a new pull request #7778: DNS: Clean up argument passing to DNS queries.

SolidWallOfCode opened a new pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778


   Rather than passing an overloaded `char *` and len, which might be an IP address, use a `union`. This makes calling cleaner as
   the `union` can have constructors for the various value types. In addition the `char const*` and length can be replaced with a `string_view`.


-- 
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.

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



[GitHub] [trafficserver] bneradt commented on a change in pull request #7778: DNS: Clean up argument passing to DNS queries.

Posted by GitBox <gi...@apache.org>.
bneradt commented on a change in pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778#discussion_r625886818



##########
File path: iocore/dns/I_DNSProcessor.h
##########
@@ -151,25 +167,31 @@ extern DNSProcessor dnsProcessor;
 inline Action *
 DNSProcessor::getSRVbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_SRV, cont, opt);
+  return getby(std::string_view(name), T_SRV, cont, opt);
+}
+
+inline Action *
+DNSProcessor::getSRVbyname(Continuation *cont, std::string_view name, Options const &opt)
+{
+  return getby(name, T_SRV, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_A, cont, opt);
+  return getby(std::string_view(name), T_A, cont, opt);
 }
 
 inline Action *
-DNSProcessor::gethostbyname(Continuation *cont, const char *name, int len, Options const &opt)
+DNSProcessor::gethostbyname(Continuation *cont, std::string_view name, Options const &opt)
 {
-  return getby(name, len, T_A, cont, opt);
+  return getby(name, T_A, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyaddr(Continuation *cont, IpAddr const *addr, Options const &opt)
 {
-  return getby(reinterpret_cast<const char *>(addr), 0, T_PTR, cont, opt);
+  return getby(*addr, T_PTR, cont, opt);
 }

Review comment:
       `addr` is dereferenced without checking for nullptr. Should addr be taken as a const reference?




-- 
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.

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



[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7778: DNS: Clean up argument passing to DNS queries.

Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778#discussion_r625976470



##########
File path: iocore/dns/I_DNSProcessor.h
##########
@@ -151,25 +167,31 @@ extern DNSProcessor dnsProcessor;
 inline Action *
 DNSProcessor::getSRVbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_SRV, cont, opt);
+  return getby(std::string_view(name), T_SRV, cont, opt);
+}
+
+inline Action *
+DNSProcessor::getSRVbyname(Continuation *cont, std::string_view name, Options const &opt)
+{
+  return getby(name, T_SRV, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_A, cont, opt);
+  return getby(std::string_view(name), T_A, cont, opt);
 }
 
 inline Action *
-DNSProcessor::gethostbyname(Continuation *cont, const char *name, int len, Options const &opt)
+DNSProcessor::gethostbyname(Continuation *cont, std::string_view name, Options const &opt)
 {
-  return getby(name, len, T_A, cont, opt);
+  return getby(name, T_A, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyaddr(Continuation *cont, IpAddr const *addr, Options const &opt)
 {
-  return getby(reinterpret_cast<const char *>(addr), 0, T_PTR, cont, opt);
+  return getby(*addr, T_PTR, cont, opt);
 }

Review comment:
       Let me try that.




-- 
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.

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



[GitHub] [trafficserver] SolidWallOfCode merged pull request #7778: DNS: Clean up argument passing to DNS queries.

Posted by GitBox <gi...@apache.org>.
SolidWallOfCode merged pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778


   


-- 
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.

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



[GitHub] [trafficserver] bneradt commented on a change in pull request #7778: DNS: Clean up argument passing to DNS queries.

Posted by GitBox <gi...@apache.org>.
bneradt commented on a change in pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778#discussion_r626025586



##########
File path: iocore/dns/I_DNSProcessor.h
##########
@@ -151,25 +167,31 @@ extern DNSProcessor dnsProcessor;
 inline Action *
 DNSProcessor::getSRVbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_SRV, cont, opt);
+  return getby(std::string_view(name), T_SRV, cont, opt);
+}
+
+inline Action *
+DNSProcessor::getSRVbyname(Continuation *cont, std::string_view name, Options const &opt)
+{
+  return getby(name, T_SRV, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_A, cont, opt);
+  return getby(std::string_view(name), T_A, cont, opt);
 }
 
 inline Action *
-DNSProcessor::gethostbyname(Continuation *cont, const char *name, int len, Options const &opt)
+DNSProcessor::gethostbyname(Continuation *cont, std::string_view name, Options const &opt)
 {
-  return getby(name, len, T_A, cont, opt);
+  return getby(name, T_A, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyaddr(Continuation *cont, IpAddr const *addr, Options const &opt)
 {
-  return getby(reinterpret_cast<const char *>(addr), 0, T_PTR, cont, opt);
+  return getby(*addr, T_PTR, cont, opt);
 }

Review comment:
       Yeah, to be clear I was assuming that we expected logically that this would not be nullptr. I was just wondering whether it made sense, that being the case, to make this a reference.




-- 
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.

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



[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7778: DNS: Clean up argument passing to DNS queries.

Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778#discussion_r625981734



##########
File path: iocore/dns/I_DNSProcessor.h
##########
@@ -151,25 +167,31 @@ extern DNSProcessor dnsProcessor;
 inline Action *
 DNSProcessor::getSRVbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_SRV, cont, opt);
+  return getby(std::string_view(name), T_SRV, cont, opt);
+}
+
+inline Action *
+DNSProcessor::getSRVbyname(Continuation *cont, std::string_view name, Options const &opt)
+{
+  return getby(name, T_SRV, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_A, cont, opt);
+  return getby(std::string_view(name), T_A, cont, opt);
 }
 
 inline Action *
-DNSProcessor::gethostbyname(Continuation *cont, const char *name, int len, Options const &opt)
+DNSProcessor::gethostbyname(Continuation *cont, std::string_view name, Options const &opt)
 {
-  return getby(name, len, T_A, cont, opt);
+  return getby(name, T_A, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyaddr(Continuation *cont, IpAddr const *addr, Options const &opt)
 {
-  return getby(reinterpret_cast<const char *>(addr), 0, T_PTR, cont, opt);
+  return getby(*addr, T_PTR, cont, opt);
 }

Review comment:
       Also, this change just moves the failure point. If you look at "DNS.cc:439" you can see the original code dereferences the pointer without checking for `nullptr`. This change simply makes it fail earlier in the call stack.




-- 
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.

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



[GitHub] [trafficserver] SolidWallOfCode commented on a change in pull request #7778: DNS: Clean up argument passing to DNS queries.

Posted by GitBox <gi...@apache.org>.
SolidWallOfCode commented on a change in pull request #7778:
URL: https://github.com/apache/trafficserver/pull/7778#discussion_r626115952



##########
File path: iocore/dns/I_DNSProcessor.h
##########
@@ -151,25 +167,31 @@ extern DNSProcessor dnsProcessor;
 inline Action *
 DNSProcessor::getSRVbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_SRV, cont, opt);
+  return getby(std::string_view(name), T_SRV, cont, opt);
+}
+
+inline Action *
+DNSProcessor::getSRVbyname(Continuation *cont, std::string_view name, Options const &opt)
+{
+  return getby(name, T_SRV, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyname(Continuation *cont, const char *name, Options const &opt)
 {
-  return getby(name, 0, T_A, cont, opt);
+  return getby(std::string_view(name), T_A, cont, opt);
 }
 
 inline Action *
-DNSProcessor::gethostbyname(Continuation *cont, const char *name, int len, Options const &opt)
+DNSProcessor::gethostbyname(Continuation *cont, std::string_view name, Options const &opt)
 {
-  return getby(name, len, T_A, cont, opt);
+  return getby(name, T_A, cont, opt);
 }
 
 inline Action *
 DNSProcessor::gethostbyaddr(Continuation *cont, IpAddr const *addr, Options const &opt)
 {
-  return getby(reinterpret_cast<const char *>(addr), 0, T_PTR, cont, opt);
+  return getby(*addr, T_PTR, cont, opt);
 }

Review comment:
       I changed the struct to have a pointer instead of an instance. Not sure why I had an instance in the first place - that forces an unnecessary copy.




-- 
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.

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