fix: small races on config registry and maxclients (#2078)

* fix small data race with maxclients
* make config::set an atomic operation
This commit is contained in:
Kostas Kyrimis 2023-10-31 09:26:15 +02:00 committed by GitHub
parent b403416be0
commit 7b71b728c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -25,7 +25,6 @@ auto ConfigRegistry::Set(std::string_view config_name, std::string_view value) -
return SetResult::READONLY;
auto cb = it->second.cb;
lk.unlock();
absl::CommandLineFlag* flag = absl::FindCommandLineFlag(config_name);
CHECK(flag);

View file

@ -439,8 +439,6 @@ bool RunEngine(ProactorPool* pool, AcceptServer* acceptor) {
}
}
service.Init(acceptor, listeners, opts);
if (!tcp_disabled) {
error_code ec = acceptor->AddListener(bind_addr, port, main_listener);
@ -458,6 +456,8 @@ bool RunEngine(ProactorPool* pool, AcceptServer* acceptor) {
acceptor->AddListener(mc_port, new Listener{Protocol::MEMCACHE, &service});
}
service.Init(acceptor, listeners, opts);
VersionMonitor version_monitor;
version_monitor.Run(pool);

View file

@ -472,7 +472,8 @@ ServerFamily::~ServerFamily() {
void SetMaxClients(std::vector<facade::Listener*>& listeners, uint32_t maxclients) {
for (auto* listener : listeners) {
if (!listener->IsPrivilegedInterface()) {
listener->SetMaxClients(maxclients);
listener->socket()->proactor()->Await(
[listener, maxclients]() { listener->SetMaxClients(maxclients); });
}
}
}