runsv: rename field in a struct to not collide with other name

no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-07-15 00:21:49 +02:00
parent 8e96b5b531
commit e46601d8a3
2 changed files with 20 additions and 19 deletions

View File

@ -90,7 +90,7 @@ typedef struct svstatus_t {
uint32_t time_nsec_be32 PACKED; uint32_t time_nsec_be32 PACKED;
uint32_t pid_le32 PACKED; uint32_t pid_le32 PACKED;
uint8_t paused; uint8_t paused;
uint8_t want; uint8_t want; /* 'u' or 'd' */
uint8_t got_term; uint8_t got_term;
uint8_t run_or_finish; uint8_t run_or_finish;
} svstatus_t; } svstatus_t;

View File

@ -78,7 +78,7 @@ struct svdir {
int pid; int pid;
smallint state; smallint state;
smallint ctrl; smallint ctrl;
smallint want; smallint sd_want;
smallint islog; smallint islog;
struct timespec start; struct timespec start;
int fdlock; int fdlock;
@ -201,7 +201,7 @@ static void update_status(struct svdir *s)
if (s->ctrl & C_PAUSE) p = add_str(p, ", paused"); if (s->ctrl & C_PAUSE) p = add_str(p, ", paused");
if (s->ctrl & C_TERM) p = add_str(p, ", got TERM"); if (s->ctrl & C_TERM) p = add_str(p, ", got TERM");
if (s->state != S_DOWN) if (s->state != S_DOWN)
switch (s->want) { switch (s->sd_want) {
case W_DOWN: case W_DOWN:
p = add_str(p, ", want down"); p = add_str(p, ", want down");
break; break;
@ -224,7 +224,7 @@ static void update_status(struct svdir *s)
status.pid_le32 = SWAP_LE32(s->pid); status.pid_le32 = SWAP_LE32(s->pid);
if (s->ctrl & C_PAUSE) if (s->ctrl & C_PAUSE)
status.paused = 1; status.paused = 1;
if (s->want == W_UP) if (s->sd_want == W_UP)
status.want = 'u'; status.want = 'u';
else else
status.want = 'd'; status.want = 'd';
@ -291,12 +291,12 @@ static void stopservice(struct svdir *s)
s->ctrl |= C_TERM; s->ctrl |= C_TERM;
update_status(s); update_status(s);
} }
if (s->want == W_DOWN) { if (s->sd_want == W_DOWN) {
kill(s->pid, SIGCONT); kill(s->pid, SIGCONT);
custom(s, 'd'); custom(s, 'd');
return; return;
} }
if (s->want == W_EXIT) { if (s->sd_want == W_EXIT) {
kill(s->pid, SIGCONT); kill(s->pid, SIGCONT);
custom(s, 'x'); custom(s, 'x');
} }
@ -360,13 +360,13 @@ static int ctrl(struct svdir *s, char c)
switch (c) { switch (c) {
case 'd': /* down */ case 'd': /* down */
s->want = W_DOWN; s->sd_want = W_DOWN;
update_status(s); update_status(s);
if (s->pid && s->state != S_FINISH) if (s->pid && s->state != S_FINISH)
stopservice(s); stopservice(s);
break; break;
case 'u': /* up */ case 'u': /* up */
s->want = W_UP; s->sd_want = W_UP;
update_status(s); update_status(s);
if (s->pid == 0) if (s->pid == 0)
startservice(s); startservice(s);
@ -374,7 +374,7 @@ static int ctrl(struct svdir *s, char c)
case 'x': /* exit */ case 'x': /* exit */
if (s->islog) if (s->islog)
break; break;
s->want = W_EXIT; s->sd_want = W_EXIT;
update_status(s); update_status(s);
/* FALLTHROUGH */ /* FALLTHROUGH */
case 't': /* sig term */ case 't': /* sig term */
@ -399,7 +399,7 @@ static int ctrl(struct svdir *s, char c)
update_status(s); update_status(s);
break; break;
case 'o': /* once */ case 'o': /* once */
s->want = W_DOWN; s->sd_want = W_DOWN;
update_status(s); update_status(s);
if (!s->pid) if (!s->pid)
startservice(s); startservice(s);
@ -459,11 +459,12 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
/* bss: svd[0].pid = 0; */ /* bss: svd[0].pid = 0; */
if (S_DOWN) svd[0].state = S_DOWN; /* otherwise already 0 (bss) */ if (S_DOWN) svd[0].state = S_DOWN; /* otherwise already 0 (bss) */
if (C_NOOP) svd[0].ctrl = C_NOOP; if (C_NOOP) svd[0].ctrl = C_NOOP;
if (W_UP) svd[0].want = W_UP; if (W_UP) svd[0].sd_want = W_UP;
/* bss: svd[0].islog = 0; */ /* bss: svd[0].islog = 0; */
/* bss: svd[1].pid = 0; */ /* bss: svd[1].pid = 0; */
gettimeofday_ns(&svd[0].start); gettimeofday_ns(&svd[0].start);
if (stat("down", &s) != -1) svd[0].want = W_DOWN; if (stat("down", &s) != -1)
svd[0].sd_want = W_DOWN;
if (stat("log", &s) == -1) { if (stat("log", &s) == -1) {
if (errno != ENOENT) if (errno != ENOENT)
@ -476,11 +477,11 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
haslog = 1; haslog = 1;
svd[1].state = S_DOWN; svd[1].state = S_DOWN;
svd[1].ctrl = C_NOOP; svd[1].ctrl = C_NOOP;
svd[1].want = W_UP; svd[1].sd_want = W_UP;
svd[1].islog = 1; svd[1].islog = 1;
gettimeofday_ns(&svd[1].start); gettimeofday_ns(&svd[1].start);
if (stat("log/down", &s) != -1) if (stat("log/down", &s) != -1)
svd[1].want = W_DOWN; svd[1].sd_want = W_DOWN;
xpiped_pair(logpipe); xpiped_pair(logpipe);
close_on_exec_on(logpipe.rd); close_on_exec_on(logpipe.rd);
close_on_exec_on(logpipe.wr); close_on_exec_on(logpipe.wr);
@ -558,10 +559,10 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
char ch; char ch;
if (haslog) if (haslog)
if (!svd[1].pid && svd[1].want == W_UP) if (!svd[1].pid && svd[1].sd_want == W_UP)
startservice(&svd[1]); startservice(&svd[1]);
if (!svd[0].pid) if (!svd[0].pid)
if (svd[0].want == W_UP || svd[0].state == S_FINISH) if (svd[0].sd_want == W_UP || svd[0].state == S_FINISH)
startservice(&svd[0]); startservice(&svd[0]);
x[0].fd = selfpipe.rd; x[0].fd = selfpipe.rd;
@ -634,11 +635,11 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
sigterm = 0; sigterm = 0;
} }
if (svd[0].want == W_EXIT && svd[0].state == S_DOWN) { if (svd[0].sd_want == W_EXIT && svd[0].state == S_DOWN) {
if (svd[1].pid == 0) if (svd[1].pid == 0)
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
if (svd[1].want != W_EXIT) { if (svd[1].sd_want != W_EXIT) {
svd[1].want = W_EXIT; svd[1].sd_want = W_EXIT;
/* stopservice(&svd[1]); */ /* stopservice(&svd[1]); */
update_status(&svd[1]); update_status(&svd[1]);
close(logpipe.wr); close(logpipe.wr);