summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-09-12 01:23:04 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-09-12 01:23:04 +0000
commit930c7fbcc1c236328d0875f857c9ae03d5ad03ec (patch)
tree5b6be43bea1ddcb30135ff78df9beaa076218dd8
parent716dde0b12532bb814c3cc8fedd99b8d16b3cf07 (diff)
downloads6-rc-930c7fbcc1c236328d0875f857c9ae03d5ad03ec.tar.xz
s6-rc-update bugfixes. Now works on nops.
-rw-r--r--doc/s6-rc.html5
-rw-r--r--src/libs6rc/s6rc_servicedir_copy_online.c7
-rw-r--r--src/s6-rc/s6-rc-compile.c1
-rw-r--r--src/s6-rc/s6-rc-init.c6
-rw-r--r--src/s6-rc/s6-rc-update.c39
5 files changed, 34 insertions, 24 deletions
diff --git a/doc/s6-rc.html b/doc/s6-rc.html
index 1000159..5cdf720 100644
--- a/doc/s6-rc.html
+++ b/doc/s6-rc.html
@@ -95,6 +95,11 @@ giving the <tt>--livedir=<em>live</em></tt> option to <tt>./configure</tt>. </li
the selection. This is useful for instance at
shutdown time: <tt>s6-rc -da change</tt>
will stop all services. </li>
+ <li> <tt>-X</tt>&nbsp;: don't lock the live state or the compile
+database. This option should never be used when s6-rc is run
+manually; it's only used by commands such as
+<a href="s6-rc-update.html">s6-rc-update</a> that spawn a s6-rc
+instance while already holding the necessary locks. </li>
</ul>
<h3> Up or down </h3>
diff --git a/src/libs6rc/s6rc_servicedir_copy_online.c b/src/libs6rc/s6rc_servicedir_copy_online.c
index 6e14844..76d9e10 100644
--- a/src/libs6rc/s6rc_servicedir_copy_online.c
+++ b/src/libs6rc/s6rc_servicedir_copy_online.c
@@ -36,7 +36,12 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst)
{
str_copy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ;
str_copy(oldfn + dstlen + 5, s6rc_servicedir_file_list[i].name) ;
- if (rename(dstfn, oldfn) < 0) { e = errno ; goto errrename ; }
+ if (rename(dstfn, oldfn) < 0
+ && (errno != ENOENT || s6rc_servicedir_file_list[i].options & SVFILE_MANDATORY))
+ {
+ e = errno ;
+ goto errrename ;
+ }
}
n = i ;
while (i--)
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index 33e53fc..f76bd57 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -524,6 +524,7 @@ static inline void add_pipeline_bundles (before_t *be)
longrun_t const *longruns = genalloc_s(longrun_t, &be->longruns) ;
unsigned int n = genalloc_len(longrun_t, &be->longruns) ;
unsigned int i = n ;
+ if (verbosity >= 2) strerr_warni1x("making bundles for pipelines") ;
while (i--) if (longruns[i].pipelinename)
{
bundle_t bundle = { .listindex = genalloc_len(unsigned int, &be->indices), .n = 1 } ;
diff --git a/src/s6-rc/s6-rc-init.c b/src/s6-rc/s6-rc-init.c
index 2337823..2043c99 100644
--- a/src/s6-rc/s6-rc-init.c
+++ b/src/s6-rc/s6-rc-init.c
@@ -59,11 +59,11 @@ int main (int argc, char const *const *argv)
if (!argc) dieusage() ;
if (compiled[0] != '/')
- strerr_dief2x(100, "compiled", " must be an absolute path") ;
+ strerr_dief2x(100, compiled, " is not an absolute path") ;
if (live[0] != '/')
- strerr_dief2x(100, "live", " must be an absolute path") ;
+ strerr_dief2x(100, live, " is not an absolute path") ;
if (argv[0][0] != '/')
- strerr_dief2x(100, "scandir", " must be an absolute path") ;
+ strerr_dief2x(100, argv[0], " is not an absolute path") ;
tain_now_g() ;
tain_add_g(&deadline, &tto) ;
diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c
index 380d79f..dcc4aeb 100644
--- a/src/s6-rc/s6-rc-update.c
+++ b/src/s6-rc/s6-rc-update.c
@@ -272,7 +272,7 @@ static inline void rollback_servicedirs (char const *newlive, unsigned char cons
byte_copy(newfn + newllen + 13, newnamelen + 1, newdb->string + newdb->services[i].name) ;
if (newstate[i] & 1)
{
- char const *oldname = newstate[i] & 4 ? olddb->string + olddb->services[invimage[i]].name : newdb->string + newdb->services[i].name ;
+ char const *oldname = newstate[i] & 8 ? olddb->string + olddb->services[invimage[i]].name : newdb->string + newdb->services[i].name ;
unsigned int oldnamelen = str_len(oldname) ;
char oldfn[livelen + 23 + oldnamelen] ;
byte_copy(oldfn, livelen, live) ;
@@ -288,18 +288,19 @@ static inline void rollback_servicedirs (char const *newlive, unsigned char cons
}
}
-static inline void unsupervise (char const *live, char const *name, int keepsupervisor)
+static inline void unsupervise (char const *llive, char const *name, int keepsupervisor)
{
unsigned int namelen = str_len(name) ;
- char fn[livelen + 14 + namelen] ;
- byte_copy(fn, livelen, live) ;
- byte_copy(fn + livelen, 9, "/scandir/") ;
- byte_copy(fn + livelen + 9, namelen + 1, name) ;
+ unsigned int llen = str_len(llive) ;
+ char fn[llen + 14 + namelen] ;
+ byte_copy(fn, llen, llive) ;
+ byte_copy(fn + llen, 9, "/scandir/") ;
+ byte_copy(fn + llen + 9, namelen + 1, name) ;
unlink(fn) ;
if (!keepsupervisor)
{
- byte_copy(fn + livelen + 1, 12, "servicedirs/") ;
- byte_copy(fn + livelen + 13, namelen + 1, name) ;
+ byte_copy(fn + llen + 1, 12, "servicedirs/") ;
+ byte_copy(fn + llen + 13, namelen + 1, name) ;
s6_svc_writectl(fn, S6_SUPERVISE_CTLDIR, "x", 1) ;
}
}
@@ -316,10 +317,9 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co
if (!s6rc_sanitize_dir(sa, live, &dirlen)) dienomem() ;
llen = sa->len ;
if (!random_sauniquename(sa, 8) || !stralloc_0(sa)) dienomem() ;
- newlen = sa->len - 1 ;
+ newlen = --sa->len ;
rm_rf(sa->s + sabase) ;
if (mkdir(sa->s + sabase, 0755) < 0) strerr_diefu2sys(111, "mkdir ", sa->s + sabase) ;
- strerr_diefu2sys(111, "mkdir ", sa->s + sabase) ;
{
unsigned int tmplen = satmp.len ;
char fn[llen - sabase + 9] ;
@@ -359,9 +359,9 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co
|| !stralloc_0(sa)) { e = errno ; goto rollback ; }
if (newstate[i] & 1)
{
- char const *oldname = newstate[i] & 4 ? olddb->string + olddb->services[invimage[i]].name : newdb->string + olddb->services[i].name ;
+ char const *oldname = newstate[i] & 8 ? olddb->string + olddb->services[invimage[i]].name : newdb->string + newdb->services[i].name ;
unsigned int oldnamelen = str_len(oldname) ;
- char oldfn[livelen + 13 + oldnamelen] ;
+ char oldfn[livelen + 14 + oldnamelen] ;
byte_copy(oldfn, livelen, live) ;
byte_copy(oldfn + livelen, 13, "/servicedirs/") ;
byte_copy(oldfn + livelen + 13, oldnamelen + 1, oldname) ;
@@ -394,12 +394,10 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co
/* scandir cleanup, then old livedir cleanup */
sa->len = dirlen ;
- sa->s[sa->len++] = '/' ;
if (!stralloc_catb(sa, satmp.s + tmpbase, satmp.len - tmpbase) || !stralloc_0(sa))
dienomem() ;
-
i = olddb->nlong ;
- while (i--) unsupervise(sa->s + sabase, olddb->string + olddb->services[i].name, oldstate[i] & 1 && !(oldstate[i] && 32)) ;
+ while (i--) unsupervise(sa->s + sabase, olddb->string + olddb->services[i].name, (oldstate[i] & 33) == 1) ;
rm_rf(sa->s + sabase) ;
sa->len = sabase ;
@@ -492,7 +490,7 @@ static void update_fdholder (s6rc_db_t const *olddb, unsigned char const *oldsta
char fnsocket[livelen + sizeof("/servicedirs/" S6RC_FDHOLDER "/s")] ;
if (!(newstate[1] & 1)) return ;
byte_copy(fnsocket, livelen, live) ;
- byte_copy(fnsocket + livelen, sizeof("/servicedirs/" S6RC_FDHOLDER "/s"), "/servicedirs" S6RC_FDHOLDER "/s") ;
+ byte_copy(fnsocket + livelen, sizeof("/servicedirs/" S6RC_FDHOLDER "/s"), "/servicedirs/" S6RC_FDHOLDER "/s") ;
fdsocket = ipc_stream_nb() ;
if (fdsocket < 0) goto hammer ;
if (!ipc_timed_connect_g(fdsocket, fnsocket, deadline))
@@ -569,16 +567,17 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (t) tain_from_millisecs(&deadline, t) ;
else deadline = tain_infinite_relative ;
}
- if (argc < 2) dieusage() ;
+ if (!argc) dieusage() ;
if (argv[0][0] != '/')
- strerr_dief2x(100, argv[0], " is not an absolute directory") ;
-
+ strerr_dief2x(100, argv[0], " is not an absolute path") ;
+ if (live[0] != '/')
+ strerr_dief2x(100, live, " is not an absolute path") ;
+ livelen = str_len(live) ;
{
int livelock, oldlock, newlock ;
int fdoldc, fdnewc ;
s6rc_db_t olddb, newdb ;
unsigned int oldn, newn ;
- unsigned int livelen = str_len(live) ;
char dbfn[livelen + 10] ;
if (!tain_now_g())