MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / linkClient

Function linkClient

src/networking.cpp:93–103  ·  view source on GitHub ↗

This function links the client to the global linked list of clients. * unlinkClient() does the opposite, among other things. */

Source from the content-addressed store, hash-verified

91/* This function links the client to the global linked list of clients.
92 * unlinkClient() does the opposite, among other things. */
93void linkClient(client *c) {
94 serverAssert(GlobalLocksAcquired());
95 listAddNodeTail(g_pserver->clients,c);
96 /* Note that we remember the linked list node where the client is stored,
97 * this way removing the client in unlinkClient() will not require
98 * a linear scan, but just a constant time operation. */
99 c->client_list_node = listLast(g_pserver->clients);
100 if (c->conn != nullptr) atomicIncr(g_pserver->rgthreadvar[c->iel].cclients, 1);
101 uint64_t id = htonu64(c->id);
102 raxInsert(g_pserver->clients_index,(unsigned char*)&id,sizeof(id),c,NULL);
103}
104
105/* Initialize client authentication state.
106 */

Callers 2

createClientFunction · 0.85

Calls 3

GlobalLocksAcquiredFunction · 0.85
listAddNodeTailFunction · 0.85
raxInsertFunction · 0.85

Tested by

no test coverage detected