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

Function execCommand

app/redis-6.2.6/src/multi.c:159–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void execCommand(client *c) {
160 int j;
161 robj **orig_argv;
162 int orig_argc;
163 struct redisCommand *orig_cmd;
164 int was_master = server.masterhost == NULL;
165
166 if (!(c->flags & CLIENT_MULTI)) {
167 addReplyError(c,"EXEC without MULTI");
168 return;
169 }
170
171 /* EXEC with expired watched key is disallowed*/
172 if (isWatchedKeyExpired(c)) {
173 c->flags |= (CLIENT_DIRTY_CAS);
174 }
175
176 /* Check if we need to abort the EXEC because:
177 * 1) Some WATCHed key was touched.
178 * 2) There was a previous error while queueing commands.
179 * A failed EXEC in the first case returns a multi bulk nil object
180 * (technically it is not an error but a special behavior), while
181 * in the second an EXECABORT error is returned. */
182 if (c->flags & (CLIENT_DIRTY_CAS | CLIENT_DIRTY_EXEC)) {
183 if (c->flags & CLIENT_DIRTY_EXEC) {
184 addReplyErrorObject(c, shared.execaborterr);
185 } else {
186 addReply(c, shared.nullarray[c->resp]);
187 }
188
189 discardTransaction(c);
190 return;
191 }
192
193 uint64_t old_flags = c->flags;
194
195 /* we do not want to allow blocking commands inside multi */
196 c->flags |= CLIENT_DENY_BLOCKING;
197
198 /* Exec all the queued commands */
199 unwatchAllKeys(c); /* Unwatch ASAP otherwise we'll waste CPU cycles */
200
201 server.in_exec = 1;
202
203 orig_argv = c->argv;
204 orig_argc = c->argc;
205 orig_cmd = c->cmd;
206 addReplyArrayLen(c,c->mstate.count);
207 for (j = 0; j < c->mstate.count; j++) {
208 c->argc = c->mstate.commands[j].argc;
209 c->argv = c->mstate.commands[j].argv;
210 c->cmd = c->mstate.commands[j].cmd;
211
212 /* ACL permissions are also checked at the time of execution in case
213 * they were changed after the commands were queued. */
214 int acl_errpos;
215 int acl_retval = ACLCheckAllPerm(c,&acl_errpos);
216 if (acl_retval != ACL_OK) {

Callers

nothing calls this directly

Calls 13

addReplyErrorFunction · 0.85
isWatchedKeyExpiredFunction · 0.85
addReplyErrorObjectFunction · 0.85
addReplyFunction · 0.85
discardTransactionFunction · 0.85
unwatchAllKeysFunction · 0.85
addReplyArrayLenFunction · 0.85
ACLCheckAllPermFunction · 0.85
addACLLogEntryFunction · 0.85
addReplyErrorFormatFunction · 0.85
feedReplicationBacklogFunction · 0.85
afterPropagateExecFunction · 0.85

Tested by

no test coverage detected