forked from extern/endlessh
Adapt max_clients on EMFILE or ENFILE
This commit is contained in:
parent
891584a361
commit
1f1ce4e26d
12
endlessh.c
12
endlessh.c
@ -267,7 +267,7 @@ main(int argc, char **argv)
|
||||
/* Wait for next event */
|
||||
if (verbose >= 2)
|
||||
logmsg("poll(%zu, %d)%s", pollvec->fill, timeout,
|
||||
nclients == max_clients ? " (no accept)" : "");
|
||||
nclients >= max_clients ? " (no accept)" : "");
|
||||
int r = poll(pollvec->fds, pollvec->fill, timeout);
|
||||
if (verbose >= 2)
|
||||
logmsg("= %d", r);
|
||||
@ -291,15 +291,19 @@ main(int argc, char **argv)
|
||||
if (fd == -1) {
|
||||
const char *msg = strerror(errno);
|
||||
switch (errno) {
|
||||
case ECONNABORTED:
|
||||
case EINTR:
|
||||
case EMFILE:
|
||||
case ENFILE:
|
||||
max_clients = nclients;
|
||||
if (verbose >= 1)
|
||||
logmsg("max clients reduced to %ld", nclients);
|
||||
break;
|
||||
case ECONNABORTED:
|
||||
case EINTR:
|
||||
case ENOBUFS:
|
||||
case ENOMEM:
|
||||
case EPROTO:
|
||||
fprintf(stderr, "endlessh: warning: %s\n", msg);
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "endlessh: fatal: %s\n", msg);
|
||||
exit(EXIT_FAILURE);
|
||||
|
Loading…
Reference in New Issue
Block a user