]> jfr.im git - solanum.git/commitdiff
librb/helper: pass our fd limit to the child
authorDoug Freed <redacted>
Fri, 21 Oct 2022 00:42:57 +0000 (20:42 -0400)
committerDoug Freed <redacted>
Fri, 21 Oct 2022 07:04:09 +0000 (03:04 -0400)
Instead of arbitrarily limiting it to 256.  This avoids an issue with
busy authds "running out" of fds because librb says no more.

librb/src/helper.c

index 593b0dc15679345a04da56081de9e2dba7ba7a6b..fb3886b37ca2e0e814c9227d25b78875de6cc412 100644 (file)
@@ -105,7 +105,7 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
        rb_helper *helper;
        const char *parv[2];
        char buf[128];
-       char fx[16], fy[16];
+       char fx[16], fy[16], maxfd[16];
        rb_fde_t *in_f[2];
        rb_fde_t *out_f[2];
        pid_t pid;
@@ -130,6 +130,7 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
 
        snprintf(fx, sizeof(fx), "%d", rb_get_fd(in_f[1]));
        snprintf(fy, sizeof(fy), "%d", rb_get_fd(out_f[0]));
+       snprintf(maxfd, sizeof(maxfd), "%d", rb_getmaxconnect());
 
        rb_set_nb(in_f[0]);
        rb_set_nb(in_f[1]);
@@ -138,7 +139,7 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
 
        rb_setenv("IFD", fy, 1);
        rb_setenv("OFD", fx, 1);
-       rb_setenv("MAXFD", "256", 1);
+       rb_setenv("MAXFD", maxfd, 1);
 
        snprintf(buf, sizeof(buf), "-ircd %s daemon", name);
        parv[0] = buf;