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

Function queueMultiCommand

src/multi.cpp:59–82  ·  view source on GitHub ↗

Add a new command into the MULTI commands queue */

Source from the content-addressed store, hash-verified

57
58/* Add a new command into the MULTI commands queue */
59void queueMultiCommand(client *c) {
60 multiCmd *mc;
61 int j;
62
63 /* No sense to waste memory if the transaction is already aborted.
64 * this is useful in case client sends these in a pipeline, or doesn't
65 * bother to read previous responses and didn't notice the multi was already
66 * aborted. */
67 if (c->flags & CLIENT_DIRTY_EXEC)
68 return;
69
70 c->mstate.commands = (multiCmd*)zrealloc(c->mstate.commands,
71 sizeof(multiCmd)*(c->mstate.count+1), MALLOC_LOCAL);
72 mc = c->mstate.commands+c->mstate.count;
73 mc->cmd = c->cmd;
74 mc->argc = c->argc;
75 mc->argv = (robj**)zmalloc(sizeof(robj*)*c->argc, MALLOC_LOCAL);
76 memcpy(mc->argv,c->argv,sizeof(robj*)*c->argc);
77 for (j = 0; j < c->argc; j++)
78 incrRefCount(mc->argv[j]);
79 c->mstate.count++;
80 c->mstate.cmd_flags |= c->cmd->flags;
81 c->mstate.cmd_inv_flags |= ~c->cmd->flags;
82}
83
84void discardTransaction(client *c) {
85 serverAssert(GlobalLocksAcquired());

Callers 2

processCommandFunction · 0.85
loadAppendOnlyFileFunction · 0.85

Calls 3

zreallocFunction · 0.85
zmallocFunction · 0.85
incrRefCountFunction · 0.85

Tested by

no test coverage detected