Add a new command into the MULTI commands queue */
| 57 | |
| 58 | /* Add a new command into the MULTI commands queue */ |
| 59 | void 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 | |
| 84 | void discardTransaction(client *c) { |
| 85 | serverAssert(GlobalLocksAcquired()); |
no test coverage detected