diff options
author | Simon Rettberg | 2024-06-26 14:44:37 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-06-26 14:44:37 +0200 |
commit | de2c98b375352ecd15fbf1d54547697a0101a025 (patch) | |
tree | 07e733209b59cd29a1bf3588024312e0204ab1be | |
parent | Remove debug spam (diff) | |
download | ldadp-de2c98b375352ecd15fbf1d54547697a0101a025.tar.gz ldadp-de2c98b375352ecd15fbf1d54547697a0101a025.tar.xz ldadp-de2c98b375352ecd15fbf1d54547697a0101a025.zip |
-rw-r--r-- | ldadp.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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) { |