MCPcopy Create free account
hub / github.com/F-Stack/f-stack / createClient

Function createClient

app/redis-6.2.6/src/networking.c:119–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119client *createClient(connection *conn) {
120 client *c = zmalloc(sizeof(client));
121
122 /* passing NULL as conn it is possible to create a non connected client.
123 * This is useful since all the commands needs to be executed
124 * in the context of a client. When commands are executed in other
125 * contexts (for instance a Lua script) we need a non connected client. */
126 if (conn) {
127 connNonBlock(conn);
128 connEnableTcpNoDelay(conn);
129 if (server.tcpkeepalive)
130 connKeepAlive(conn,server.tcpkeepalive);
131 connSetReadHandler(conn, readQueryFromClient);
132 connSetPrivateData(conn, c);
133 }
134
135 selectDb(c,0);
136 uint64_t client_id;
137 atomicGetIncr(server.next_client_id, client_id, 1);
138 c->id = client_id;
139 c->resp = 2;
140 c->conn = conn;
141 c->name = NULL;
142 c->bufpos = 0;
143 c->qb_pos = 0;
144 c->querybuf = sdsempty();
145 c->pending_querybuf = sdsempty();
146 c->querybuf_peak = 0;
147 c->reqtype = 0;
148 c->argc = 0;
149 c->argv = NULL;
150 c->argv_len_sum = 0;
151 c->original_argc = 0;
152 c->original_argv = NULL;
153 c->cmd = c->lastcmd = NULL;
154 c->multibulklen = 0;
155 c->bulklen = -1;
156 c->sentlen = 0;
157 c->flags = 0;
158 c->ctime = c->lastinteraction = server.unixtime;
159 clientSetDefaultAuth(c);
160 c->replstate = REPL_STATE_NONE;
161 c->repl_put_online_on_ack = 0;
162 c->reploff = 0;
163 c->read_reploff = 0;
164 c->repl_ack_off = 0;
165 c->repl_ack_time = 0;
166 c->repl_last_partial_write = 0;
167 c->slave_listening_port = 0;
168 c->slave_addr = NULL;
169 c->slave_capa = SLAVE_CAPA_NONE;
170 c->reply = listCreate();
171 c->reply_bytes = 0;
172 c->obuf_soft_limit_reached_time = 0;
173 listSetFreeMethod(c->reply,freeClientReplyValue);
174 listSetDupMethod(c->reply,dupClientReplyValue);
175 c->btype = BLOCKED_NONE;
176 c->bpop.timeout = 0;

Callers 9

scriptingInitFunction · 0.70
acceptCommonHandlerFunction · 0.70
RM_CallFunction · 0.70
moduleBlockClientFunction · 0.70
RM_GetThreadSafeContextFunction · 0.70
moduleFireServerEventFunction · 0.70

Calls 13

zmallocFunction · 0.85
connNonBlockFunction · 0.85
connEnableTcpNoDelayFunction · 0.85
connKeepAliveFunction · 0.85
connSetReadHandlerFunction · 0.85
connSetPrivateDataFunction · 0.85
selectDbFunction · 0.85
sdsemptyFunction · 0.85
clientSetDefaultAuthFunction · 0.85
listCreateFunction · 0.85
linkClientFunction · 0.85
initClientMultiStateFunction · 0.85

Tested by

no test coverage detected