This function links the client to the global linked list of clients. * unlinkClient() does the opposite, among other things. */
| 91 | /* This function links the client to the global linked list of clients. |
| 92 | * unlinkClient() does the opposite, among other things. */ |
| 93 | void 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 | */ |
no test coverage detected