librb/helper: pass our fd limit to the child

Instead of arbitrarily limiting it to 256.  This avoids an issue with 
busy authds "running out" of fds because librb says no more.
This commit is contained in:
Doug Freed 2022-10-20 20:42:57 -04:00
parent f085388a74
commit 33822550e5

View file

@ -105,7 +105,7 @@ rb_helper_start(const char *name, const char *fullpath, rb_helper_cb * read_cb,
rb_helper *helper; rb_helper *helper;
const char *parv[2]; const char *parv[2];
char buf[128]; char buf[128];
char fx[16], fy[16]; char fx[16], fy[16], maxfd[16];
rb_fde_t *in_f[2]; rb_fde_t *in_f[2];
rb_fde_t *out_f[2]; rb_fde_t *out_f[2];
pid_t pid; 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(fx, sizeof(fx), "%d", rb_get_fd(in_f[1]));
snprintf(fy, sizeof(fy), "%d", rb_get_fd(out_f[0])); 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[0]);
rb_set_nb(in_f[1]); 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("IFD", fy, 1);
rb_setenv("OFD", fx, 1); rb_setenv("OFD", fx, 1);
rb_setenv("MAXFD", "256", 1); rb_setenv("MAXFD", maxfd, 1);
snprintf(buf, sizeof(buf), "-ircd %s daemon", name); snprintf(buf, sizeof(buf), "-ircd %s daemon", name);
parv[0] = buf; parv[0] = buf;