]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/srvrec.cc
tests: fail testsuccess if notices are shown, too
[apt.git] / apt-pkg / contrib / srvrec.cc
index 837f2c84ea28b1d4fbea19d42f0e6edae3216575..be159bad932f40e08a046e96b2d83e1fac239ce1 100644 (file)
@@ -16,6 +16,7 @@
 #include <time.h>
 
 #include <algorithm>
+#include <tuple>
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include "srvrec.h"
 
 
+bool SrvRec::operator==(SrvRec const &other) const
+{
+   return (std::tie(target, priority, weight, port) ==
+           std::tie(other.target, other.priority, other.weight, other.port));
+}
+
 bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result)
 {
    std::string target;
-   struct servent *s_ent = getservbyport(htons(port), "tcp");
-   if (s_ent == NULL)
+   int res;
+   struct servent s_ent_buf;
+   struct servent *s_ent = nullptr;
+   std::vector<char> buf(1024);
+
+   res = getservbyport_r(htons(port), "tcp", &s_ent_buf, buf.data(), buf.size(), &s_ent);
+   if (res != 0 || s_ent == nullptr)
       return false;
 
    strprintf(target, "_%s._tcp.%s", s_ent->s_name, host.c_str());