MCPcopy Create free account
hub / github.com/apache/kvrocks / AddConnection

Method AddConnection

src/server/worker.cc:345–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345Status Worker::AddConnection(redis::Connection *c) {
346 std::unique_lock<std::mutex> lock(conns_mu_);
347 auto iter = conns_.find(c->GetFD());
348 if (iter != conns_.end()) {
349 return {Status::NotOK, "connection was exists"};
350 }
351
352 int max_clients = srv->GetConfig()->maxclients;
353 if (srv->IncrClientNum() >= max_clients) {
354 srv->DecrClientNum();
355 return {Status::NotOK, "max number of clients reached"};
356 }
357
358 conns_.emplace(c->GetFD(), c);
359 uint64_t id = srv->GetClientID();
360 c->SetID(id);
361
362 return Status::OK();
363}
364
365redis::Connection *Worker::removeConnection(int fd) {
366 redis::Connection *conn = nullptr;

Callers 1

MigrateConnectionMethod · 0.80

Calls 7

GetFDMethod · 0.80
endMethod · 0.80
IncrClientNumMethod · 0.80
DecrClientNumMethod · 0.80
GetClientIDMethod · 0.80
SetIDMethod · 0.80
GetConfigMethod · 0.45

Tested by

no test coverage detected