]> granicus.if.org Git - pdns/commitdiff
If accept() returns EAGAIN, Socket::accept() returns a null pointer
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 7 Oct 2017 08:28:35 +0000 (10:28 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 7 Oct 2017 08:28:35 +0000 (10:28 +0200)
pdns/sstuff.hh
pdns/webserver.cc
pdns/ws-recursor.cc

index e7fb6ee9ab2fddf8bf1c299b5c0075af22fc1a6d..707b1ad12b2b23da3ebe03a482e4dab49ff8de1c 100644 (file)
@@ -96,7 +96,7 @@ public:
     int s=::accept(d_socket,(sockaddr *)&remote, &remlen);
     if(s<0) {
       if(errno==EAGAIN)
-        return 0;
+        return nullptr;
 
       throw NetworkError("Accepting a connection: "+string(strerror(errno)));
     }
index 09e838ac0ee98eb191698d2c116d7ad1c2bdfd33..7cfba4153b6b711151e9c927a8a0bc6c300aa8b2 100644 (file)
@@ -350,6 +350,9 @@ void WebServer::go()
     while(true) {
       try {
         auto client = d_server->accept();
+        if (!client) {
+          continue;
+        }
         if (client->acl(acl)) {
           std::thread webHandler(WebServerConnectionThreadStart, this, client);
           webHandler.detach();
index f590bd12b70eb51284972505d270d05e715aee4d..e54d81258628fe5c1cfdcfce679ff1589eccf7cd 100644 (file)
@@ -541,7 +541,9 @@ void AsyncServerNewConnectionMT(void *p) {
   AsyncServer *server = (AsyncServer*)p;
   try {
     auto socket = server->accept();
-    server->d_asyncNewConnectionCallback(socket);
+    if (socket) {
+      server->d_asyncNewConnectionCallback(socket);
+    }
   } catch (NetworkError &e) {
     // we're running in a shared process/thread, so can't just terminate/abort.
     return;