]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #7685 from Habbie/dnsdist-macos
authorRemi Gacogne <rgacogne@users.noreply.github.com>
Tue, 9 Apr 2019 11:47:12 +0000 (13:47 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Apr 2019 11:47:12 +0000 (13:47 +0200)
dnsdist: collected portability fixes

pdns/iputils.cc
pdns/pollmplexer.cc
pdns/tcpreceiver.cc
regression-tests.dnsdist/test_TCPLimits.py

index 8abe2873ededdeb31aeddbc1847a50f12ef0d20c..84425e66cb08514ecbacfdb92e716f266b77d91f 100644 (file)
@@ -336,7 +336,7 @@ size_t sendMsgWithTimeout(int fd, const char* buffer, size_t len, int idleTimeou
       if (errno == EINTR) {
         continue;
       }
-      else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS) {
+      else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) {
         /* EINPROGRESS might happen with non blocking socket,
            especially with TCP Fast Open */
         if (totalTimeout <= 0 && idleTimeout <= 0) {
index 8e3e8b1d3a054ba6e5857cec87f4686c74bab43d..399ad132ae8a3bd6dca4d566d2ed03fa952584e4 100644 (file)
@@ -104,7 +104,7 @@ void PollFDMultiplexer::getAvailableFDs(std::vector<int>& fds, int timeout)
     throw FDMultiplexerException("poll returned error: " + stringerror());
 
   for(const auto& pollfd : pollfds) {
-    if (pollfd.revents == POLLIN || pollfd.revents == POLLOUT) {
+    if (pollfd.revents & POLLIN || pollfd.revents & POLLOUT) {
       fds.push_back(pollfd.fd);
     }
   }
@@ -128,7 +128,7 @@ int PollFDMultiplexer::run(struct timeval* now, int timeout)
   d_inrun=true;
 
   for(const auto& pollfd : pollfds) {
-    if(pollfd.revents == POLLIN) {
+    if(pollfd.revents & POLLIN) {
       d_iter=d_readCallbacks.find(pollfd.fd);
     
       if(d_iter != d_readCallbacks.end()) {
@@ -136,7 +136,7 @@ int PollFDMultiplexer::run(struct timeval* now, int timeout)
         continue; // so we don't refind ourselves as writable!
       }
     }
-    else if(pollfd.revents == POLLOUT) {
+    else if(pollfd.revents & POLLOUT) {
       d_iter=d_writeCallbacks.find(pollfd.fd);
     
       if(d_iter != d_writeCallbacks.end()) {
index 706305c87aa718be343b0308dee1ce78b9383ade..9c0a7b80c11256ca94fd0f56833d20e51f7b64b0 100644 (file)
@@ -1352,7 +1352,7 @@ void TCPNameserver::thread()
 
       int sock=-1;
       for(const pollfd& pfd :  d_prfds) {
-        if(pfd.revents == POLLIN) {
+        if(pfd.revents & POLLIN) {
           sock = pfd.fd;
           remote.sin4.sin_family = AF_INET6;
           addrlen=remote.getSocklen();
index 7652347d0c0193cbea54f60450f1f3fde433c469..ec20c929f5966591f857c55e9e0d9a2e52730f37 100644 (file)
@@ -106,11 +106,11 @@ class TestTCPLimits(DNSDistTest):
         conn.send(struct.pack("!H", 65535))
 
         count = 0
-        while count < (self._maxTCPConnDuration * 2):
+        while count < (self._maxTCPConnDuration * 20):
             try:
                 # sleeping for only one second keeps us below the
                 # idle timeout (setTCPRecvTimeout())
-                time.sleep(1)
+                time.sleep(0.1)
                 conn.send(b'A')
                 count = count + 1
             except Exception as e:
@@ -119,7 +119,7 @@ class TestTCPLimits(DNSDistTest):
 
         end = time.time()
 
-        self.assertAlmostEquals(count, self._maxTCPConnDuration, delta=2)
+        self.assertAlmostEquals(count / 10, self._maxTCPConnDuration, delta=2)
         self.assertAlmostEquals(end - start, self._maxTCPConnDuration, delta=2)
 
         conn.close()