~sircmpwn/gmni-devel

1

[PATCH] Close some files when too many are open

Rémy Noulin <loader2x@gmail.com>
Details
Message ID
<CACoVjN1mJOfvNLugo_Z_qTio0LXnqXppaEebpJOiTCYjtj9o=g@mail.gmail.com>
DKIM signature
pass
Download raw message
src/server.c | 6 ++++++
1 file changed, 6 insertions(+)
---
 src/server.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/server.c b/src/server.c
index 56e11c9..7eafda9 100644
--- a/src/server.c
+++ b/src/server.c
@@ -115,6 +115,12 @@ accept_client(struct gmnisrv_server *server, int fd)
     int sockfd = accept(fd, &addr, &addrlen);
     if (sockfd == -1) {
         server_error("accept error: %s", strerror(errno));
+        if (errno == 24) {
+            for (int i = 1; i < 4; i++) {
+                struct gmnisrv_client *client =
&server->clients[server->nclients-i];
+                disconnect_client(server, client);
+            }
+        }
         return;
     }

-- 
2.35.1
Details
Message ID
<CNI43FAGU1N1.1CR1RYZ9BS49K@taiga>
In-Reply-To
<CACoVjN1mJOfvNLugo_Z_qTio0LXnqXppaEebpJOiTCYjtj9o=g@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Wed Sep 28, 2022 at 3:12 PM CEST, Rémy Noulin wrote:
> src/server.c | 6 ++++++
> 1 file changed, 6 insertions(+)
> ---
>  src/server.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/server.c b/src/server.c
> index 56e11c9..7eafda9 100644
> --- a/src/server.c
> +++ b/src/server.c
> @@ -115,6 +115,12 @@ accept_client(struct gmnisrv_server *server, int fd)
>      int sockfd = accept(fd, &addr, &addrlen);
>      if (sockfd == -1) {
>          server_error("accept error: %s", strerror(errno));
> +        if (errno == 24) {

Do not use a constant here, use ENFILE
Reply to thread Export thread (mbox)