aboutsummaryrefslogtreecommitdiffstats
path: root/init/init.c
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-12-07 11:40:11 -0800
committerSteve Kondik <shade@chemlab.org>2012-12-07 11:50:58 -0800
commitf6c28026d99cebbede1e60b9ffb41ff6f65a160a (patch)
tree3d27c374b54a5f3f2afd079311977d46ddcc8f60 /init/init.c
parentc3b3837623549170e321645b6d8ab3bb49d44d0d (diff)
downloadsystem_core-f6c28026d99cebbede1e60b9ffb41ff6f65a160a.tar.gz
system_core-f6c28026d99cebbede1e60b9ffb41ff6f65a160a.tar.bz2
system_core-f6c28026d99cebbede1e60b9ffb41ff6f65a160a.zip
Revert "init: Never allow two same-service processes to exist simultaneously."
This reverts commit abe57d0b4e994e31eb31ec98dfa6d4b74e29502e. Revert "Restart oneshot services when manually restarted." This reverts commit e889a4746b6f3cd1c6749312c255b14eedc5f778. Revert "Safely restart services to avoid race conditions." This reverts commit 9d1a567eb0d6ac8d0040228e7c41668c8e3eb37e.
Diffstat (limited to 'init/init.c')
-rwxr-xr-xinit/init.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/init/init.c b/init/init.c
index 4f334cba..1f76bcd1 100755
--- a/init/init.c
+++ b/init/init.c
@@ -182,7 +182,7 @@ void service_start(struct service *svc, const char *dynamic_args)
* state and immediately takes it out of the restarting
* state if it was in there
*/
- svc->flags &= (~(SVC_DISABLED|SVC_RESTARTING|SVC_RESET|SVC_RESTART));
+ svc->flags &= (~(SVC_DISABLED|SVC_RESTARTING|SVC_RESET));
svc->time_started = 0;
/* running processes require no additional work -- if
@@ -395,14 +395,15 @@ void service_start(struct service *svc, const char *dynamic_args)
notify_service_state(svc->name, "running");
}
-/* The how field should be either SVC_DISABLED, SVC_RESET, or SVC_RESTART */
+/* The how field should be either SVC_DISABLED or SVC_RESET */
static void service_stop_or_reset(struct service *svc, int how)
{
- /* The service is still SVC_RUNNING until its process exits, but if it has
- * already exited it shoudn't attempt a restart yet. */
- svc->flags &= (~SVC_RESTARTING);
+ /* we are no longer running, nor should we
+ * attempt to restart
+ */
+ svc->flags &= (~(SVC_RUNNING|SVC_RESTARTING));
- if ((how != SVC_DISABLED) && (how != SVC_RESET) && (how != SVC_RESTART)) {
+ if ((how != SVC_DISABLED) && (how != SVC_RESET)) {
/* Hrm, an illegal flag. Default to SVC_DISABLED */
how = SVC_DISABLED;
}
@@ -434,17 +435,6 @@ void service_stop(struct service *svc)
service_stop_or_reset(svc, SVC_DISABLED);
}
-void service_restart(struct service *svc)
-{
- if (svc->flags & SVC_RUNNING) {
- /* Stop, wait, then start the service. */
- service_stop_or_reset(svc, SVC_RESTART);
- } else if (!(svc->flags & SVC_RESTARTING)) {
- /* Just start the service since it's not running. */
- service_start(svc, NULL);
- } /* else: Service is restarting anyways. */
-}
-
void property_changed(const char *name, const char *value)
{
if (property_triggers_enabled)
@@ -511,17 +501,6 @@ static void msg_stop(const char *name)
}
}
-static void msg_restart(const char *name)
-{
- struct service *svc = service_find_by_name(name);
-
- if (svc) {
- service_restart(svc);
- } else {
- ERROR("no such service '%s'\n", name);
- }
-}
-
void handle_control_message(const char *msg, const char *arg)
{
if (!strcmp(msg,"start")) {
@@ -529,7 +508,8 @@ void handle_control_message(const char *msg, const char *arg)
} else if (!strcmp(msg,"stop")) {
msg_stop(arg);
} else if (!strcmp(msg,"restart")) {
- msg_restart(arg);
+ msg_stop(arg);
+ msg_start(arg);
} else {
ERROR("unknown control msg '%s'\n", msg);
}