Lines Matching refs:c
35 void initClientMultiState(client *c) { in initClientMultiState() argument
36 c->mstate.commands = NULL; in initClientMultiState()
37 c->mstate.count = 0; in initClientMultiState()
41 void freeClientMultiState(client *c) { in freeClientMultiState() argument
44 for (j = 0; j < c->mstate.count; j++) { in freeClientMultiState()
46 multiCmd *mc = c->mstate.commands+j; in freeClientMultiState()
52 zfree(c->mstate.commands); in freeClientMultiState()
56 void queueMultiCommand(client *c) { in queueMultiCommand() argument
60 c->mstate.commands = zrealloc(c->mstate.commands, in queueMultiCommand()
61 sizeof(multiCmd)*(c->mstate.count+1)); in queueMultiCommand()
62 mc = c->mstate.commands+c->mstate.count; in queueMultiCommand()
63 mc->cmd = c->cmd; in queueMultiCommand()
64 mc->argc = c->argc; in queueMultiCommand()
65 mc->argv = zmalloc(sizeof(robj*)*c->argc); in queueMultiCommand()
66 memcpy(mc->argv,c->argv,sizeof(robj*)*c->argc); in queueMultiCommand()
67 for (j = 0; j < c->argc; j++) in queueMultiCommand()
69 c->mstate.count++; in queueMultiCommand()
72 void discardTransaction(client *c) { in discardTransaction() argument
73 freeClientMultiState(c); in discardTransaction()
74 initClientMultiState(c); in discardTransaction()
75 c->flags &= ~(CLIENT_MULTI|CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC); in discardTransaction()
76 unwatchAllKeys(c); in discardTransaction()
81 void flagTransaction(client *c) { in flagTransaction() argument
82 if (c->flags & CLIENT_MULTI) in flagTransaction()
83 c->flags |= CLIENT_DIRTY_EXEC; in flagTransaction()
86 void multiCommand(client *c) { in multiCommand() argument
87 if (c->flags & CLIENT_MULTI) { in multiCommand()
88 addReplyError(c,"MULTI calls can not be nested"); in multiCommand()
91 c->flags |= CLIENT_MULTI; in multiCommand()
92 addReply(c,shared.ok); in multiCommand()
95 void discardCommand(client *c) { in discardCommand() argument
96 if (!(c->flags & CLIENT_MULTI)) { in discardCommand()
97 addReplyError(c,"DISCARD without MULTI"); in discardCommand()
100 discardTransaction(c); in discardCommand()
101 addReply(c,shared.ok); in discardCommand()
106 void execCommandPropagateMulti(client *c) { in execCommandPropagateMulti() argument
109 propagate(server.multiCommand,c->db->id,&multistring,1, in execCommandPropagateMulti()
114 void execCommand(client *c) { in execCommand() argument
121 if (!(c->flags & CLIENT_MULTI)) { in execCommand()
122 addReplyError(c,"EXEC without MULTI"); in execCommand()
132 if (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC)) { in execCommand()
133 addReply(c, c->flags & CLIENT_DIRTY_EXEC ? shared.execaborterr : in execCommand()
135 discardTransaction(c); in execCommand()
140 unwatchAllKeys(c); /* Unwatch ASAP otherwise we'll waste CPU cycles */ in execCommand()
141 orig_argv = c->argv; in execCommand()
142 orig_argc = c->argc; in execCommand()
143 orig_cmd = c->cmd; in execCommand()
144 addReplyMultiBulkLen(c,c->mstate.count); in execCommand()
145 for (j = 0; j < c->mstate.count; j++) { in execCommand()
146 c->argc = c->mstate.commands[j].argc; in execCommand()
147 c->argv = c->mstate.commands[j].argv; in execCommand()
148 c->cmd = c->mstate.commands[j].cmd; in execCommand()
154 if (!must_propagate && !(c->cmd->flags & CMD_READONLY)) { in execCommand()
155 execCommandPropagateMulti(c); in execCommand()
159 call(c,CMD_CALL_FULL); in execCommand()
162 c->mstate.commands[j].argc = c->argc; in execCommand()
163 c->mstate.commands[j].argv = c->argv; in execCommand()
164 c->mstate.commands[j].cmd = c->cmd; in execCommand()
166 c->argv = orig_argv; in execCommand()
167 c->argc = orig_argc; in execCommand()
168 c->cmd = orig_cmd; in execCommand()
169 discardTransaction(c); in execCommand()
181 replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc); in execCommand()
202 void watchForKey(client *c, robj *key) { in watchForKey() argument
209 listRewind(c->watched_keys,&li); in watchForKey()
212 if (wk->db == c->db && equalStringObjects(key,wk->key)) in watchForKey()
216 clients = dictFetchValue(c->db->watched_keys,key); in watchForKey()
219 dictAdd(c->db->watched_keys,key,clients); in watchForKey()
222 listAddNodeTail(clients,c); in watchForKey()
226 wk->db = c->db; in watchForKey()
228 listAddNodeTail(c->watched_keys,wk); in watchForKey()
233 void unwatchAllKeys(client *c) { in unwatchAllKeys() argument
237 if (listLength(c->watched_keys) == 0) return; in unwatchAllKeys()
238 listRewind(c->watched_keys,&li); in unwatchAllKeys()
247 serverAssertWithInfo(c,NULL,clients != NULL); in unwatchAllKeys()
248 listDelNode(clients,listSearchKey(clients,c)); in unwatchAllKeys()
253 listDelNode(c->watched_keys,ln); in unwatchAllKeys()
274 client *c = listNodeValue(ln); in touchWatchedKey() local
276 c->flags |= CLIENT_DIRTY_CAS; in touchWatchedKey()
291 client *c = listNodeValue(ln); in touchWatchedKeysOnFlush() local
292 listRewind(c->watched_keys,&li2); in touchWatchedKeysOnFlush()
301 c->flags |= CLIENT_DIRTY_CAS; in touchWatchedKeysOnFlush()
307 void watchCommand(client *c) { in watchCommand() argument
310 if (c->flags & CLIENT_MULTI) { in watchCommand()
311 addReplyError(c,"WATCH inside MULTI is not allowed"); in watchCommand()
314 for (j = 1; j < c->argc; j++) in watchCommand()
315 watchForKey(c,c->argv[j]); in watchCommand()
316 addReply(c,shared.ok); in watchCommand()
319 void unwatchCommand(client *c) { in unwatchCommand() argument
320 unwatchAllKeys(c); in unwatchCommand()
321 c->flags &= (~CLIENT_DIRTY_CAS); in unwatchCommand()
322 addReply(c,shared.ok); in unwatchCommand()