From: W.C.A. Wijngaards Date: Fri, 12 Aug 2022 07:54:29 +0000 (+0200) Subject: - Fix to log accept error ENFILE and EMFILE errno, but slowly, once X-Git-Tag: release-1.17.0rc1~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc6c04b24382acca435878d6edb12dcc17cf3ca2;p=thirdparty%2Funbound.git - 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. --- diff --git a/doc/Changelog b/doc/Changelog index 24605888b..0e67bf0b1 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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. diff --git a/util/netevent.c b/util/netevent.c index 841e09787..c2b1ac7d4 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -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; } diff --git a/util/netevent.h b/util/netevent.h index 9f4d28ba9..4e82703e0 100644 --- a/util/netevent.h +++ b/util/netevent.h @@ -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.