Skip to content

Commit 6cc49e5

Browse files
committed
server: move swd to main service
Signed-off-by: Abhijat Malviya <[email protected]>
1 parent 5106b6b commit 6cc49e5

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

src/server/main_service.cc

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,13 @@ struct ShutdownWatchdog {
159159
};
160160

161161
ShutdownWatchdog::ShutdownWatchdog(util::ProactorPool& pp) : pool{pp} {
162-
watchdog_fb = pool.GetNextProactor()->LaunchFiber([&] {
163-
util::ThisFiber::SetName("shutdown-watchdog");
164-
162+
watchdog_fb = pool.GetNextProactor()->LaunchFiber("shutdown_watchdog", [&] {
165163
if (!watchdog_done.WaitFor(20s)) {
166164
LOG(ERROR) << "Deadlock detected during shutdown";
167165
absl::SetFlag(&FLAGS_alsologtostderr, true);
168166
util::fb2::Mutex m;
169167
pool.AwaitFiberOnAll([&m](unsigned index, auto*) {
170-
util::ThisFiber::SetName("shutdown-watchdog");
168+
util::ThisFiber::SetName(absl::StrFormat("print_stack_fib_%u", index));
171169
std::unique_lock lk(m);
172170
LOG(ERROR) << "Proactor " << index << ":\n";
173171
util::fb2::detail::FiberInterface::PrintAllFiberStackTraces();
@@ -181,7 +179,7 @@ void ShutdownWatchdog::Disarm() {
181179
watchdog_fb.JoinIfNeeded();
182180
}
183181

184-
std::optional<ShutdownWatchdog> swd = std::nullopt;
182+
std::optional<ShutdownWatchdog> shutdown_watchdog = std::nullopt;
185183

186184
} // namespace
187185

@@ -1113,6 +1111,9 @@ void Service::Shutdown() {
11131111
cluster_family_.Shutdown();
11141112

11151113
server_family_.Shutdown();
1114+
1115+
shutdown_watchdog.emplace(pp_);
1116+
11161117
engine_varz.reset();
11171118

11181119
ChannelStore::Destroy();
@@ -1127,7 +1128,7 @@ void Service::Shutdown() {
11271128
ThisFiber::SleepFor(10ms);
11281129
facade::Connection::Shutdown();
11291130

1130-
DisarmShutdownWatchdog();
1131+
shutdown_watchdog->Disarm();
11311132
}
11321133

11331134
OpResult<KeyIndex> Service::FindKeys(const CommandId* cid, CmdArgList args) {
@@ -3107,16 +3108,4 @@ const acl::AclFamily* Service::TestInit() {
31073108
return &acl_family_;
31083109
}
31093110

3110-
void ArmShutdownWatchdog(ProactorPool& pp) {
3111-
if (!swd.has_value()) {
3112-
swd.emplace(pp);
3113-
}
3114-
}
3115-
3116-
void DisarmShutdownWatchdog() {
3117-
if (swd.has_value()) {
3118-
swd->Disarm();
3119-
}
3120-
}
3121-
31223111
} // namespace dfly

src/server/main_service.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,4 @@ class Service : public facade::ServiceInterface {
203203
uint32_t loading_state_counter_ ABSL_GUARDED_BY(mu_) = 0;
204204
};
205205

206-
void ArmShutdownWatchdog(util::ProactorPool& pp);
207-
208-
void DisarmShutdownWatchdog();
209-
210206
} // namespace dfly

src/server/server_family.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,6 @@ void ServerFamily::Shutdown() {
12201220
});
12211221
}
12221222

1223-
ArmShutdownWatchdog(service_.proactor_pool());
1224-
12251223
client_pause_ec_.await([this] { return active_pauses_.load() == 0; });
12261224

12271225
pb_task_->Await([this] {

0 commit comments

Comments
 (0)