summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-06-26 14:44:37 +0200
committerSimon Rettberg2024-06-26 14:44:37 +0200
commitde2c98b375352ecd15fbf1d54547697a0101a025 (patch)
tree07e733209b59cd29a1bf3588024312e0204ab1be
parentRemove debug spam (diff)
downloadldadp-master.tar.gz
ldadp-master.tar.xz
ldadp-master.zip
Also bail out on accept errors if autoRestart is enabledHEADmaster
-rw-r--r--ldadp.c11
1 files 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) {