fix: forbid parallel save operations (#2172)

* fix: forbid parallel save operations

* feat: add SAVE option to takeover command
This commit is contained in:
Borys 2023-11-21 13:56:27 +02:00 committed by GitHub
parent c10dac4db2
commit e6f3522d59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 165 additions and 83 deletions

View file

@ -2290,17 +2290,17 @@ VarzValue::Map Service::GetVarzStats() {
return res;
}
GlobalState Service::SwitchState(GlobalState from, GlobalState to) {
std::pair<GlobalState, bool> Service::SwitchState(GlobalState from, GlobalState to) {
lock_guard lk(mu_);
if (global_state_ != from)
return global_state_;
return {global_state_, false};
VLOG(1) << "Switching state from " << GlobalStateName(from) << " to " << GlobalStateName(to);
global_state_ = to;
pp_.Await([&](ProactorBase*) { ServerState::tlocal()->set_gstate(to); });
return to;
return {to, true};
}
GlobalState Service::GetGlobalState() const {