Merge "Fix race condition between restart and stop/reset." am: ee14225e0d am: 5c5a6bdc87
am: 8b0654925d
Change-Id: I432f815f2b40208d3f3949a033973ee4dd179a9a
diff --git a/init/service.cpp b/init/service.cpp
index 45e3f06..12acfc6 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -960,6 +960,13 @@
} else {
flags_ |= how;
}
+ // Make sure it's in right status when a restart immediately follow a
+ // stop/reset or vice versa.
+ if (how == SVC_RESTART) {
+ flags_ &= (~(SVC_DISABLED | SVC_RESET));
+ } else {
+ flags_ &= (~SVC_RESTART);
+ }
if (pid_) {
KillProcessGroup(SIGKILL);