summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2024-06-17 14:22:02 +0000
committerLaurent Bercot <ska@appnovation.com>2024-06-17 14:22:02 +0000
commit398133d1553522d1acc1a070644c42d17f22709f (patch)
treee078ef4228e6ba91de4387dbc2fade833f235039 /src
parentb7634d9e7946092f9fecd33dbbd89b86b5701bed (diff)
downloads6-rc-398133d1553522d1acc1a070644c42d17f22709f.tar.xz
Prepare for 0.5.4.4 ; fix fds limit in s6rc-fdholderd
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/s6-rc/s6-rc-compile.c13
-rw-r--r--src/s6-rc/s6-rc-update.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index 350662d..0247053 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -1087,6 +1087,7 @@ static inline void write_oneshot_runner (char const *compiled, int blocking)
static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, char const *fdhuser)
{
+ unsigned int nfds = 0 ;
size_t base = satmp.len ;
char fn[61 + S6RC_FDHOLDER_LEN] = "servicedirs/" S6RC_FDHOLDER "/data/rules/uid/0/env" ;
make_skel(compiled, S6RC_FDHOLDER, 1) ;
@@ -1106,8 +1107,12 @@ static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, ch
for (uint32_t j = 0 ; j < db->nlong ; j++)
if (db->services[j].x.longrun.nproducers)
+ {
if (!stralloc_cats(&satmp, db->string + db->services[j].name)
|| !stralloc_catb(&satmp, "\n", 1)) dienomem() ;
+ nfds += 2 ;
+ }
+ if (nfds < 240) nfds = 256 ; else nfds += (nfds >> 4) + 2 ;
auto_file(compiled, "servicedirs/" S6RC_FDHOLDER "/data/autofilled", satmp.s + base, satmp.len - base) ;
satmp.len = base ;
@@ -1129,7 +1134,13 @@ static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, ch
|| !string_quote(&satmp, fdhuser, strlen(fdhuser))
|| !stralloc_catb(&satmp, "\n", 1)) dienomem() ;
}
- if (!stralloc_cats(&satmp, S6_EXTBINPREFIX "s6-fdholder-daemon -1 ")) dienomem() ;
+ if (!stralloc_cats(&satmp, S6_EXTBINPREFIX "s6-fdholder-daemon -1 -n ")) dienomem() ;
+ {
+ char fmt[UINT_FMT] ;
+ size_t len = uint_fmt(fmt, nfds) ;
+ fmt[len++] = ' ' ;
+ if (!stralloc_catb(&satmp, fmt, len)) dienomem() ;
+ }
if (fdhuser)
{
if (!stralloc_cats(&satmp, "-U ")) dienomem() ;
diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c
index 7387e07..830214d 100644
--- a/src/s6-rc/s6-rc-update.c
+++ b/src/s6-rc/s6-rc-update.c
@@ -535,7 +535,7 @@ static inline void update_fdholder (s6rc_db_t const *olddb, unsigned char const
pid_t pid ;
int wstat ;
char tfmt[UINT_FMT] ;
- char const *newargv[7] = { S6_EXTBINPREFIX "s6-svc", "-T", tfmt, "-twR", "--", fnsocket, 0 } ;
+ char const *newargv[7] = { S6_EXTBINPREFIX "s6-svc", "-T", tfmt, "-rwR", "--", fnsocket, 0 } ;
fill_tfmt(tfmt, deadline) ;
fnsocket[livelen + sizeof("/servicedirs/" S6RC_FDHOLDER) - 1] = 0 ;
pid = cspawn(newargv[0], newargv, envp, 0, 0, 0) ;