]> granicus.if.org Git - pdns/commitdiff
dnsdist: Handle h2o_evloop_run() returning -1 with errno set to EINTR
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 19 Apr 2019 15:04:44 +0000 (17:04 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 19 Apr 2019 15:04:44 +0000 (17:04 +0200)
pdns/dnsdistdist/doh.cc

index 5e01af7d6b5092ee564111b62fcd046f7b8a6767..12d4d698345d2bd04e222cbd7c9e00bda8427aaf 100644 (file)
@@ -711,12 +711,22 @@ try
     throw std::runtime_error("DOH server failed to listen on " + df->d_local.toStringWithPort() + ": " + strerror(errno));
   }
 
-  while (h2o_evloop_run(dsc->h2o_ctx.loop, INT32_MAX) == 0)
-    ;
- }
- catch(const std::exception& e) {
-   throw runtime_error("DOH thread failed to launch: " + std::string(e.what()));
- }
- catch(...) {
-   throw runtime_error("DOH thread failed to launch");
- }
+  bool stop = false;
+  do {
+    int result = h2o_evloop_run(dsc->h2o_ctx.loop, INT32_MAX);
+    if (result == -1) {
+      if (errno != EINTR) {
+        errlog("Error in the DoH event loop: %s", strerror(errno));
+        stop = true;
+      }
+    }
+  }
+  while (stop == false);
+
+}
+catch(const std::exception& e) {
+  throw runtime_error("DOH thread failed to launch: " + std::string(e.what()));
+}
+catch(...) {
+  throw runtime_error("DOH thread failed to launch");
+}