]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix to log accept error ENFILE and EMFILE errno, but slowly, once
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 12 Aug 2022 07:54:29 +0000 (09:54 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 12 Aug 2022 07:54:29 +0000 (09:54 +0200)
  per 10 seconds. Also log accept failures when no slow down is used.

doc/Changelog
util/netevent.c
util/netevent.h

index 24605888b377e9a1d7cfd8300f85402893929e65..0e67bf0b19f7317f8b3470c2348429380980b05f 100644 (file)
@@ -1,3 +1,7 @@
+12 August 2022: Wouter
+       - Fix to log accept error ENFILE and EMFILE errno, but slowly, once
+         per 10 seconds. Also log accept failures when no slow down is used.
+
 5 August 2022: Wouter
        - Fix #734 [FR] enable unbound-checkconf to detect more (basic)
          errors.
index 841e0978738fd65bd3b2716e6bf48e9c0df3fb32..c2b1ac7d4397b6fa9974e6a485f13b238fd27777 100644 (file)
@@ -132,6 +132,8 @@ struct internal_base {
        struct ub_event* slow_accept;
        /** true if slow_accept is enabled */
        int slow_accept_enabled;
+       /** last log time for slow logging of file descriptor errors */
+       time_t last_slow_log;
 };
 
 /**
@@ -889,6 +891,15 @@ int comm_point_perform_accept(struct comm_point* c,
                                struct timeval tv;
                                verbose(VERB_ALGO, "out of file descriptors: "
                                        "slow accept");
+                               ub_comm_base_now(b);
+                               if(b->eb->last_slow_log+SLOW_LOG_TIME <=
+                                       b->eb->secs) {
+                                       b->eb->last_slow_log = b->eb->secs;
+                                       log_err("accept failed, slow down "
+                                               "accept for %d msec: %s",
+                                               NETEVENT_SLOW_ACCEPT_TIME,
+                                               sock_strerror(errno));
+                               }
                                b->eb->slow_accept_enabled = 1;
                                fptr_ok(fptr_whitelist_stop_accept(
                                        b->stop_accept));
@@ -909,6 +920,9 @@ int comm_point_perform_accept(struct comm_point* c,
                                        /* we do not want to log here,
                                         * error: "event_add failed." */
                                }
+                       } else {
+                               log_err("accept, with no slow down, "
+                                       "failed: %s", sock_strerror(errno));
                        }
                        return -1;
                }
index 9f4d28ba9f8f41ebd7427df5a255f99986f6edc1..4e82703e078187bca9411f0a9afe30924b009ed1 100644 (file)
@@ -102,6 +102,8 @@ typedef int comm_point_callback_type(struct comm_point*, void*, int,
 
 /** timeout to slow accept calls when not possible, in msec. */
 #define NETEVENT_SLOW_ACCEPT_TIME 2000
+/** timeout to slow down log print, so it does not spam the logs, in sec */
+#define SLOW_LOG_TIME 10
 
 /**
  * A communication point dispatcher. Thread specific.