summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-09-27 17:01:15 +0000
committerLaurent Bercot <ska@appnovation.com>2021-09-27 17:01:15 +0000
commitaf8a277de03d7e265cc03c1aa6a80f800227b73e (patch)
tree56b7154b18e945bd432489c847cdcd6f671b9d83 /src
parent3d1af077642991bb68d1288665dac5b666b02512 (diff)
downloads6-rc-af8a277de03d7e265cc03c1aa6a80f800227b73e.tar.xz
Die at compile time when notification-fd == lock-fd
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/s6-rc/s6-rc-compile.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index 84f7bdc..b0ec688 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -1254,6 +1254,7 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db,
{
size_t srcdirlen = strlen(srcdirs[i]) ;
size_t len = strlen(db->string + db->services[i].name) ;
+ unsigned int fdnotif = 0 ;
unsigned int u ;
int ispipelined = db->services[i].x.longrun.nproducers || db->services[i].x.longrun.consumer < db->nlong ;
char srcfn[srcdirlen + len + 18] ;
@@ -1303,20 +1304,38 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db,
memcpy(srcfn + srcdirlen + len + 2, "notification-fd", 16) ;
memcpy(dstfn + clen + 14 + len, "notification-fd", 16) ;
- if (copy_uint(compiled, srcfn, dstfn, &u) && u < 3 && verbosity)
+ if (copy_uint(compiled, srcfn, dstfn, &u))
{
- char fmt[UINT_FMT] ;
- fmt[uint_fmt(fmt, u)] = 0 ;
- strerr_warnw4x("longrun ", db->string + db->services[i].name, " has a notification-fd of ", fmt) ;
+ if (u < 3)
+ {
+ if (verbosity)
+ {
+ char fmt[UINT_FMT] ;
+ fmt[uint_fmt(fmt, u)] = 0 ;
+ strerr_warnw4x("longrun ", db->string + db->services[i].name, " has a notification-fd of ", fmt) ;
+ }
+ }
+ else fdnotif = u ;
}
memcpy(srcfn + srcdirlen + len + 2, "lock-fd", 8) ;
memcpy(dstfn + clen + 14 + len, "lock-fd", 8) ;
- if (copy_uint(compiled, srcfn, dstfn, &u) && u < 3 && verbosity)
+ if (copy_uint(compiled, srcfn, dstfn, &u))
{
- char fmt[UINT_FMT] ;
- fmt[uint_fmt(fmt, u)] = 0 ;
- strerr_warnw4x("longrun ", db->string + db->services[i].name, " has a lock-fd of ", fmt) ;
+ if (u < 3)
+ {
+ if (verbosity)
+ {
+ char fmt[UINT_FMT] ;
+ fmt[uint_fmt(fmt, u)] = 0 ;
+ strerr_warnw4x("longrun ", db->string + db->services[i].name, " has a lock-fd of ", fmt) ;
+ }
+ }
+ else if (fdnotif == u)
+ {
+ cleanup(compiled) ;
+ strerr_dief3x(1, "longrun ", db->string + db->services[i].name, " has the same value for notification-fd and lock-fd") ;
+ }
}
memcpy(srcfn + srcdirlen + len + 2, "timeout-kill", 13) ;