diff --git a/sslh-fork.c b/sslh-fork.c index 139338a..74335d7 100644 --- a/sslh-fork.c +++ b/sslh-fork.c @@ -178,6 +178,25 @@ void tcp_listener(struct listen_endpoint* endpoint, int num_endpoints, int activ while (1) { in_socket = accept(endpoint[active_endpoint].socketfd, 0, 0); CHECK_RES_RETURN(in_socket, "accept", /*void*/ ); + if (in_socket == -1) { + print_message(msg_system_error, "%s:%d:%s:%d:%s\n", + __FILE__, __LINE__, "accept", errno, strerror(errno)); + switch(in_socket) { + case ENETDOWN: /* accept(2) cites all these errnos as "you should retry" */ + case EPROTO: + case ENOPROTOOPT: + case EHOSTDOWN: + case ENONET: + case EHOSTUNREACH: + case EOPNOTSUPP: + case ENETUNREACH: + case ECONNABORTED: + continue; + + default: /* Otherwise, it's something wrong in our parameters, we fail */ + return; + } + } print_message(msg_fd, "accepted fd %d\n", in_socket); switch(fork()) {