Skip to content

Commit

Permalink
main/fd_listen: return EMFILE if maxfds is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Sep 4, 2024
1 parent 1bf492a commit fc14fc6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,13 @@ int fd_listen(struct re_fhs **fhsp, re_sock_t fd, int flags, fd_h *fh,

DEBUG_INFO("fd_listen/new: fd=%d flags=0x%02x\n", fd, flags);

++re->nfds;
if (++re->nfds > re->maxfds) {
DEBUG_WARNING("fd_listen maxfds reached %d > %d\n",
re->nfds, re->maxfds);
--re->nfds;
err = EMFILE;
goto out;
}
}
else {
if (unlikely(fhs->fd != fd)) {
Expand Down Expand Up @@ -649,6 +655,7 @@ int fd_listen(struct re_fhs **fhsp, re_sock_t fd, int flags, fd_h *fh,
break;
}

out:
if (err) {
mem_deref(fhs);
DEBUG_WARNING("fd_listen err: fd=%d flags=0x%02x (%m)\n", fd,
Expand Down

0 comments on commit fc14fc6

Please sign in to comment.