s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 0ba5fd00ec4e1e25bb868b2b5a7b98d24b56197e
parent 394619babd409dfede6bdce61699981b893183ba
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sat, 25 Sep 2021 09:45:27 +0000

 Doc fixes, s6-socklog min linelen -> 76, s6-ioconnect fixes

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
Mdoc/s6-socklog.html | 6+++---
Mdoc/s6-svlink.html | 4++--
Mdoc/s6-svunlink.html | 8++++----
Msrc/conn-tools/s6-ioconnect.c | 42++++++++++++++++++++++--------------------
Msrc/daemontools-extras/s6-socklog.c | 2+-
5 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/doc/s6-socklog.html b/doc/s6-socklog.html @@ -45,7 +45,7 @@ with a few more features. <ul> <li> Messages are truncated to 1024 characters </li> <li> Trailing nulls or newlines are removed </li> - <li> Embedded nulls or newlines are converted to <tt>~</tt> characters (tildas) </li> + <li> Embedded nulls or newlines are converted to <tt>~</tt> characters (tildes) </li> <li> A <tt>&lt;syslogcode&gt;</tt> at the beginning of the line is converted to <tt>facility.priority: </tt> </li> </ul> </li> <li> It prints the log line to its stdout, terminated by a newline. </li> @@ -80,7 +80,7 @@ will not be converted to facility/priority names. </li> (actually bound to its socket), write a newline to file descriptor <em>notif</em> then close it. This allows <tt>s6-socklog</tt> to use the <a href="notifywhenup.html">s6 -mechanism to notify readiness</a>. <em>notif</em> cannot be lesser than 3. +mechanism to notify readiness</a>. <em>notif</em> cannot be less than 3. If this option is not given, no readiness notification is sent. </li> <li> <tt>-u&nbsp;<em>uid</em></tt>&nbsp;: drop user id to <em>uid</em> </li> <li> <tt>-g&nbsp;<em>gid</em></tt>&nbsp;: drop group id to <em>gid</em> </li> @@ -92,7 +92,7 @@ to the values of the UID, GID and GIDLIST environment variables. If a <tt>-u</tt <tt>-g</tt> or <tt>-G</tt> option is given after <tt>-U</tt>, the command line value overrides the environment variable. </li> <li> <tt>-l</tt>&nbsp;<em>linelen</em>&nbsp;: Set the maximum datagram size to -<em>linelen</em>. Default is 1024. It cannot be set to less than 80 or more than +<em>linelen</em>. Default is 1024. It cannot be set to less than 76 or more than 1048576. If a datagram is bigger than <em>linelen</em>, it will be truncated to <em>linelen</em> characters, and the logged line will end with a <tt>...</tt> ellipsis to show the truncation. </li> diff --git a/doc/s6-svlink.html b/doc/s6-svlink.html @@ -48,7 +48,7 @@ is named <em>name</em>; if no <em>name</em> argument has been given, the name gi to the symbolic link is the basename of <em>servicedir</em>. </li> <li> It sends a command to <a href="s6-svscan.html">s6-svscan</a> to signal it that a new service is available. </li> - <li> It waits for a <a href="s6-supervise.html">s6-supervise</a> process to be + <li> It waits for an <a href="s6-supervise.html">s6-supervise</a> process to be spawned on <em>servicedir</em>. </li> <li> It exits 0. </li> </ul> @@ -105,7 +105,7 @@ supervisors one at a time, can be used instead. </li> <li> If <em>servicedir</em> is logged, i.e. <em>servicedir</em><tt>/log</tt> is also a valid service directory, then <tt>s6-svlink</tt> will wait until supervisors have been spawned for both the service and its logger. </li> - <li> <tt>s6-svlink</tt> sends a <a href="s6-svscanctl.html">s6-svscanctl -a</a> + <li> <tt>s6-svlink</tt> sends an <a href="s6-svscanctl.html">s6-svscanctl -a</a> command to <em>scandir</em>, which means that the system's view of services will be refreshed. Depending on what links exist in <em>scandir</em>, other services than <em>servicedir</em> may also appear. </li> diff --git a/doc/s6-svunlink.html b/doc/s6-svunlink.html @@ -65,14 +65,14 @@ managing the service directory to exit. </li> <li> <tt>-X</tt>&nbsp;: don't wait. <tt>s6-svunlink</tt> will exit right away, without waiting for the supervisor to exit first. </li> <li> <tt>-t&nbsp;<em>timeout</em></tt>&nbsp;: if the supervisor has not exited -after <em>timeout</em> milliseconds, <tt>s6-svlink</tt> will still exit. -The default is 0, meaning no time limit.. </li> +after <em>timeout</em> milliseconds, <tt>s6-svunlink</tt> will still exit. +The default is 0, meaning no time limit. </li> </ul> <h2> Notes </h2> <ul> - <li> Using <tt>s6-svlink</tt> to stop services is a suboptimal pattern: + <li> Using <tt>s6-svunlink</tt> to stop services is a suboptimal pattern: starting and stopping supervisors is a heavier operation than just stopping services. The simpler, more efficient pattern is to simply perform <a href="s6-svc.html">s6-svc -dwD <em>scandir</em><tt>/</tt><em>name</em></a>, @@ -84,7 +84,7 @@ situations that are nominal failures. For instance, it returns 0 even if its timeout expires; the rationale is that there is no sensible action for the user to do if this error is reported. <tt>s6-svunlink</tt> only reports errors when they uncover a deeper problem in the system. </li> - <li> <tt>s6-svunlink</tt> sends a <a href="s6-svscanctl.html">s6-svscanctl -an</a> + <li> <tt>s6-svunlink</tt> sends an <a href="s6-svscanctl.html">s6-svscanctl -an</a> command to <em>scandir</em>, which means that the system's view of services will be refreshed and inactive services will be killed and unsupervised. Depending on what links exist in <em>scandir</em>, new diff --git a/src/conn-tools/s6-ioconnect.c b/src/conn-tools/s6-ioconnect.c @@ -29,7 +29,7 @@ struct ioblah_s unsigned int flagopen : 1 ; } ; -static ioblah_t a[2][2] = { { { 0, 4, 0, 1 }, { 7, 4, 0, 1 } }, { { 6, 4, 0, 1 }, { 1, 4, 0, 1 } } } ; +static ioblah_t a[2][2] = { { { 0, 5, 0, 1 }, { 7, 5, 0, 1 } }, { { 6, 5, 0, 1 }, { 1, 5, 0, 1 } } } ; static iobuffer b[2] ; static iopause_fd x[5] = { { -1, IOPAUSE_READ, 0 } } ; @@ -123,22 +123,22 @@ int main (int argc, char const *const *argv) tain_add_g(&deadline, iobuffer_isempty(&b[0]) && iobuffer_isempty(&b[1]) ? &tto : &tain_infinite_relative) ; for (i = 0 ; i < 2 ; i++) { - a[i][0].xindex = 5 ; if (a[i][0].flagopen && iobuffer_isreadable(&b[i])) { x[xlen].fd = a[i][0].fd ; x[xlen].events = IOPAUSE_READ ; a[i][0].xindex = xlen++ ; } - a[i][1].xindex = 5 ; + else a[i][0].xindex = 5 ; if (a[i][1].flagopen) { x[xlen].fd = a[i][1].fd ; x[xlen].events = IOPAUSE_EXCEPT | (iobuffer_isempty(&b[i]) ? 0 : IOPAUSE_WRITE) ; a[i][1].xindex = xlen++ ; } + else a[i][1].xindex = 5 ; } - if (xlen <= 1) break ; + if (xlen == 1 || (xlen == 2 && (x[1].fd == a[0][0].fd || x[1].fd == a[1][0].fd))) break ; r = iopause_g(x, xlen, &deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; @@ -148,14 +148,7 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < 2 ; i++) if (a[i][1].xindex < 5) { - if (x[a[i][1].xindex].revents & IOPAUSE_WRITE) - { - if (!iobuffer_flush(&b[i])) - { - if (!error_isagain(errno)) x[a[i][1].xindex].revents |= IOPAUSE_EXCEPT ; - } - else if (!a[i][0].flagopen) finishit(i) ; - } + int dead = 0 ; if (x[a[i][1].xindex].revents & IOPAUSE_EXCEPT) { if (!iobuffer_isempty(&b[i])) @@ -165,13 +158,26 @@ int main (int argc, char const *const *argv) iobuffer_flush(&b[i]) ; /* sets errno */ strerr_warnwu2sys("write to fd ", fmt) ; } - closeit(i, 0) ; finishit(i) ; + dead = 1 ; + } + else if (x[a[i][1].xindex].revents & IOPAUSE_WRITE) + { + if (!iobuffer_flush(&b[i])) + { + if (!error_isagain(errno)) dead = 1 ; + } + else if (!a[i][0].flagopen) dead = 1 ; + } + if (dead) + { + if (!a[i][0].flagopen) closeit(i, 0) ; + finishit(i) ; } } for (i = 0 ; i < 2 ; i++) if (a[i][0].xindex < 5) { - if (x[a[i][0].xindex].revents & IOPAUSE_READ) + if (x[a[i][0].xindex].revents & (IOPAUSE_READ | IOPAUSE_EXCEPT)) { if (sanitize_read(iobuffer_fill(&b[i])) < 0) { @@ -181,14 +187,10 @@ int main (int argc, char const *const *argv) fmt[uint_fmt(fmt, a[i][0].fd)] = 0 ; strerr_warnwu2sys("read from fd ", fmt) ; } - x[a[i][0].xindex].revents |= IOPAUSE_EXCEPT ; + closeit(i, 0) ; + if (iobuffer_isempty(&b[i])) finishit(i) ; } } - if (x[a[i][0].xindex].revents & IOPAUSE_EXCEPT) - { - closeit(i, 0) ; - if (iobuffer_isempty(&b[i])) finishit(i) ; - } } } return 0 ; diff --git a/src/daemontools-extras/s6-socklog.c b/src/daemontools-extras/s6-socklog.c @@ -104,7 +104,7 @@ int main (int argc, char const *const *argv) } argc -= l.ind ; argv += l.ind ; - if (linelen < 80) linelen = 80 ; + if (linelen < 76) linelen = 76 ; if (linelen > 1048576) linelen = 1048576 ; if (t) tain_from_millisecs(&lameducktto, t) ; if (notif)