Fix race condition between restart and stop/reset.

If there is a restart follow a stop/reset immediately or vice versa,
clear previous flag bits.

Test: manual - trigger restart after stop immediately to check if
service get started.

Change-Id: I4503177d7cb5ed054dbcf50cd8e09728415404d4
This commit is contained in:
Tao Wu 2017-10-27 11:29:13 -07:00
parent 41a9b3c81d
commit 84b856d901
1 changed files with 7 additions and 0 deletions

View File

@ -940,6 +940,13 @@ void Service::StopOrReset(int how) {
} 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);