From de2c98b375352ecd15fbf1d54547697a0101a025 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 26 Jun 2024 14:44:37 +0200 Subject: Also bail out on accept errors if autoRestart is enabled --- ldadp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ldadp.c b/ldadp.c index 2152903..0a63671 100644 --- a/ldadp.c +++ b/ldadp.c @@ -116,11 +116,18 @@ static void listen_callback(void *data, int haveIn, int haveOut, int doCleanup) epoll_listen_t *listen = (epoll_listen_t *)data; char remote[4]; uint16 port; + static unsigned int accept_fails = 0; int sock = socket_accept4(listen->fd, remote, &port); - if (sock < 0) { - printf("[Proxy] Error accepting new connection.\n"); + if (sock == -1) { + printf("[Proxy] Error accepting new connection (%d)\n", errno); + if (_autoRestart && ++accept_fails > 10) { + bail("Too many accept failures"); + } return; } + if (accept_fails > 0) { + accept_fails--; + } helper_nonblock(sock); SSL *ssl = NULL; if (listen->sslContext != NULL) { -- cgit v1.2.3-55-g7522