Gentoo Archives: gentoo-commits

From: Christian Ruppert <idl0r@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/
Date: Sat, 31 Dec 2011 02:36:17
Message-Id: 34b7632d1d2ed38c7251ac8c2869c8fc416a99f5.idl0r@gentoo
1 commit: 34b7632d1d2ed38c7251ac8c2869c8fc416a99f5
2 Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 31 02:35:32 2011 +0000
4 Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 31 02:35:32 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=34b7632d
7
8 Do not exit immediately when a service has been stopped already
9
10 The old behaviour was to exit(EXIT_SUCCESS) in case the service has been stopped
11 already, even if further commands has been passed to the init script
12 (like zap, start).
13 So using for example /etc/init.d/foo stop zap start would abort immediately
14 after "stop" if the service has been stopped already. Though there may be cases
15 were we need it to proceed with the remaining commands, zap and start in this
16 case.
17 This patch fixes the behaviour to continue and proceed with the remaining
18 commands whenever necessary.
19
20 X-Gentoo-Bug: 371845
21 X-Gentoo-Bug-URL: https://bugs.gentoo.org/371845
22
23 ---
24 src/rc/runscript.c | 16 +++++++++++-----
25 1 files changed, 11 insertions(+), 5 deletions(-)
26
27 diff --git a/src/rc/runscript.c b/src/rc/runscript.c
28 index cd53b34..2f66971 100644
29 --- a/src/rc/runscript.c
30 +++ b/src/rc/runscript.c
31 @@ -821,7 +821,7 @@ svc_start(void)
32 svc_start_real();
33 }
34
35 -static void
36 +static int
37 svc_stop_check(RC_SERVICE *state)
38 {
39 *state = rc_service_state(service);
40 @@ -848,7 +848,7 @@ svc_stop_check(RC_SERVICE *state)
41
42 if (*state & RC_SERVICE_STOPPED) {
43 ewarn("WARNING: %s is already stopped", applet);
44 - exit(EXIT_SUCCESS);
45 + return 1;
46 }
47
48 rc_service_mark(service, RC_SERVICE_STOPPING);
49 @@ -861,6 +861,8 @@ svc_stop_check(RC_SERVICE *state)
50 else if (rc_service_in_runlevel(service, RC_LEVEL_BOOT))
51 ewarn("WARNING: you are stopping a boot service");
52 }
53 +
54 + return 0;
55 }
56
57 static void
58 @@ -986,7 +988,7 @@ svc_stop_real(void)
59 rc_plugin_run(RC_HOOK_SERVICE_STOP_OUT, applet);
60 }
61
62 -static void
63 +static int
64 svc_stop(void)
65 {
66 RC_SERVICE state;
67 @@ -995,13 +997,16 @@ svc_stop(void)
68 if (dry_run)
69 einfon("stop:");
70 else
71 - svc_stop_check(&state);
72 + if (svc_stop_check(&state) == 1)
73 + return 1; /* Service has been stopped already */
74 if (deps)
75 svc_stop_deps(state);
76 if (dry_run)
77 printf(" %s\n", applet);
78 else
79 svc_stop_real();
80 +
81 + return 0;
82 }
83
84 static void
85 @@ -1351,7 +1356,8 @@ runscript(int argc, char **argv)
86 }
87 if (deps && in_background)
88 get_started_services();
89 - svc_stop();
90 + if (svc_stop() == 1)
91 + continue; /* Service has been stopped already */
92 if (deps) {
93 if (!in_background &&
94 !rc_runlevel_stopping() &&