Switch to disable bin. exp. wait time in RS

This commit is contained in:
Lionel Sambuc 2013-02-16 16:50:18 +01:00
parent f240e1eaf5
commit c3ae1bdfcd
7 changed files with 34 additions and 14 deletions

View file

@ -4,7 +4,7 @@ SRCS.service=service.c parse.c util.c
SRCS.printconfig=print.c parse.c util.c
BINDIR= /bin
MAN.service=
MAN.service= service.8
MAN.printconfig=
CPPFLAGS+= -I${NETBSDSRCDIR}

View file

@ -3,7 +3,7 @@
service \- Manage an operating system service.
.SH SYNOPSIS
.PP
\fBservice [-c -r -n -p] (up|run|edit|update)\fR \fI<binary|self>\fR
\fBservice [-b -c -n -p -r] (up|run|edit|update)\fR \fI<binary|self>\fR
[\fB-args\fR \fI<args>\fR] [\fB-dev\fR \fI<special>\fR]
[\fB-devstyle\fR \fI<style>\fR] [\fB-period\fR \fI<ticks>\fR]
[\fB-script\fR \fI<path>\fR] [\fB-label\fR \fI<name>\fR]
@ -63,6 +63,9 @@ it down allowing for graceful degradation of service. If a critical
system service fails to restart, \fBRS\fR will immediately resort to
a system-wide panic. The \fBup\fR action takes the following options:
.TP
.BI \-b " "
disable the usage of binary exponential restart time in \fBRS\fR.
.TP
.BI \-c " "
\fBRS\fR normally relies on the binary on the disk to restart a
system service. The
@ -72,10 +75,6 @@ use the copy to restart the service upon termination. This is necessary
when the location on the disk may change or if the service itself is
required to read the binary from the disk (e.g. the disk driver).
.TP
.BI \-r " "
when saving an in-memory copy, instructs \fBRS\fR to reuse and share the copy
of an existing service with the same program name, if available.
.TP
.BI \-n " "
by default, \fBRS\fR performs blocking startup of the system service. As
a result, the \fBup\fR action does not terminate until the system service
@ -92,6 +91,10 @@ and use the replica to restart the service upon termination. This is
necessary when the service itself is required to create a working
service instance (e.g. \fBPM\fR).
.TP
.BI \-r " "
when saving an in-memory copy, instructs \fBRS\fR to reuse and share the copy
of an existing service with the same program name, if available.
.TP
.BI \-args " <args>"
specifies the command line arguments to use to run the program
given by \fI<binary>\fR. The default is to use no arguments.

View file

@ -161,20 +161,24 @@ static int parse_arguments(int argc, char **argv, u32_t *rss_flags)
char *hz, *buff;
int req_nr;
int c, i, j;
int c_flag, r_flag, n_flag, p_flag;
int b_flag, c_flag, r_flag, n_flag, p_flag;
int label_required;
b_flag = 0;
c_flag = 0;
r_flag = 0;
n_flag = 0;
p_flag = 0;
while (c= getopt(argc, argv, "rcnp?"), c != -1)
while (c= getopt(argc, argv, "rbcnp?"), c != -1)
{
switch(c)
{
case '?':
print_usage(argv[ARG_NAME], "wrong number of arguments");
exit(EINVAL);
case 'b':
b_flag = 1;
break;
case 'c':
c_flag = 1;
break;
@ -236,6 +240,9 @@ static int parse_arguments(int argc, char **argv, u32_t *rss_flags)
if(p_flag)
*rss_flags |= RSS_REPLICA;
if(b_flag)
*rss_flags |= RSS_NO_BIN_EXP;
req_path = argv[optind+ARG_PATH];
if(req_nr == RS_UPDATE && !strcmp(req_path, SELF_BINARY)) {
/* Self update needs no real path or configuration file. */

View file

@ -28,6 +28,7 @@ Interface to the reincarnation server
#define RSS_SELF_LU 0x20 /* perform self update */
#define RSS_SYS_BASIC_CALLS 0x40 /* include basic kernel calls */
#define RSS_VM_BASIC_CALLS 0x80 /* include basic vm calls */
#define RSS_NO_BIN_EXP 0x100 /* suppress binary exponential offset */
/* Common definitions. */
#define RS_NR_CONTROL 8

View file

@ -7,7 +7,7 @@ MAN= add_route.8 backup.8 boot.8 btrace.8 \
ossdevlinks.8 part.8 partition.8 \
poweroff.8 printroot.8 pr_routes.8 pwdauth.8 rarpd.8 \
rdate.8 readclock.8 reboot.8 repartition.8 \
rshd.8 screendump.8 serial-ip.8 service.8 \
rshd.8 screendump.8 serial-ip.8 \
setup.8 shutdown.8 slip.8 srccrc.8 syslogd.8 tcpd.8 \
unix.8 update.8 usage.8 vbfs.8

View file

@ -42,8 +42,9 @@
#define SF_USE_COPY 0x008 /* set when process has a copy in memory */
#define SF_NEED_REPL 0x010 /* set when process needs replica to start */
#define SF_USE_REPL 0x020 /* set when process has a replica */
#define SF_NO_BIN_EXP 0x040 /* set when we should ignore binary exp. offset */
#define IMM_SF \
(SF_CORE_SRV | SF_SYNCH_BOOT | SF_NEED_COPY | SF_NEED_REPL) /* immutable */
(SF_NO_BIN_EXP | SF_CORE_SRV | SF_SYNCH_BOOT | SF_NEED_COPY | SF_NEED_REPL) /* immutable */
/* Constants determining RS period and binary exponential backoff. */
#define RS_INIT_T (system_hz * 10) /* allow T ticks for init */

View file

@ -1066,10 +1066,15 @@ void terminate_service(struct rproc *rp)
* a binary exponential backoff.
*/
if (rp->r_restarts > 0) {
if (!(rpub->sys_flags & SF_NO_BIN_EXP)) {
rp->r_backoff = 1 << MIN(rp->r_restarts,(BACKOFF_BITS-2));
rp->r_backoff = MIN(rp->r_backoff,MAX_BACKOFF);
if ((rpub->sys_flags & SF_USE_COPY) && rp->r_backoff > 1)
rp->r_backoff= 1;
}
else {
rp->r_backoff = 1;
}
return;
}
@ -1545,6 +1550,9 @@ endpoint_t source;
if (rs_start->rss_flags & RSS_REPLICA) {
rpub->sys_flags |= SF_USE_REPL;
}
if (rs_start->rss_flags & RSS_NO_BIN_EXP) {
rpub->sys_flags |= SF_NO_BIN_EXP;
}
/* Update period. */
if(rpub->endpoint != RS_PROC_NR) {