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()
38 c->mstate.cmd_flags = 0; in initClientMultiState()
42 void freeClientMultiState(client *c) { in freeClientMultiState() argument
45 for (j = 0; j < c->mstate.count; j++) { in freeClientMultiState()
47 multiCmd *mc = c->mstate.commands+j; in freeClientMultiState()
53 zfree(c->mstate.commands); in freeClientMultiState()
57 void queueMultiCommand(client *c) { in queueMultiCommand() argument
61 c->mstate.commands = zrealloc(c->mstate.commands, in queueMultiCommand()
62 sizeof(multiCmd)*(c->mstate.count+1)); in queueMultiCommand()
63 mc = c->mstate.commands+c->mstate.count; in queueMultiCommand()
64 mc->cmd = c->cmd; in queueMultiCommand()
65 mc->argc = c->argc; in queueMultiCommand()
66 mc->argv = zmalloc(sizeof(robj*)*c->argc); in queueMultiCommand()
67 memcpy(mc->argv,c->argv,sizeof(robj*)*c->argc); in queueMultiCommand()
68 for (j = 0; j < c->argc; j++) in queueMultiCommand()
70 c->mstate.count++; in queueMultiCommand()
71 c->mstate.cmd_flags |= c->cmd->flags; in queueMultiCommand()
74 void discardTransaction(client *c) { in discardTransaction() argument
75 freeClientMultiState(c); in discardTransaction()
76 initClientMultiState(c); in discardTransaction()
77 c->flags &= ~(CLIENT_MULTI|CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC); in discardTransaction()
78 unwatchAllKeys(c); in discardTransaction()
83 void flagTransaction(client *c) { in flagTransaction() argument
84 if (c->flags & CLIENT_MULTI) in flagTransaction()
85 c->flags |= CLIENT_DIRTY_EXEC; in flagTransaction()
88 void multiCommand(client *c) { in multiCommand() argument
89 if (c->flags & CLIENT_MULTI) { in multiCommand()
90 addReplyError(c,"MULTI calls can not be nested"); in multiCommand()
93 c->flags |= CLIENT_MULTI; in multiCommand()
94 addReply(c,shared.ok); in multiCommand()
97 void discardCommand(client *c) { in discardCommand() argument
98 if (!(c->flags & CLIENT_MULTI)) { in discardCommand()
99 addReplyError(c,"DISCARD without MULTI"); in discardCommand()
102 discardTransaction(c); in discardCommand()
103 addReply(c,shared.ok); in discardCommand()
108 void execCommandPropagateMulti(client *c) { in execCommandPropagateMulti() argument
111 propagate(server.multiCommand,c->db->id,&multistring,1, in execCommandPropagateMulti()
116 void execCommand(client *c) { in execCommand() argument
124 if (!(c->flags & CLIENT_MULTI)) { in execCommand()
125 addReplyError(c,"EXEC without MULTI"); in execCommand()
135 if (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC)) { in execCommand()
136 addReply(c, c->flags & CLIENT_DIRTY_EXEC ? shared.execaborterr : in execCommand()
138 discardTransaction(c); in execCommand()
148 !(c->flags & CLIENT_MASTER) && c->mstate.cmd_flags & CMD_WRITE) in execCommand()
150 addReplyError(c, in execCommand()
153 discardTransaction(c); in execCommand()
158 unwatchAllKeys(c); /* Unwatch ASAP otherwise we'll waste CPU cycles */ in execCommand()
159 orig_argv = c->argv; in execCommand()
160 orig_argc = c->argc; in execCommand()
161 orig_cmd = c->cmd; in execCommand()
162 addReplyMultiBulkLen(c,c->mstate.count); in execCommand()
163 for (j = 0; j < c->mstate.count; j++) { in execCommand()
164 c->argc = c->mstate.commands[j].argc; in execCommand()
165 c->argv = c->mstate.commands[j].argv; in execCommand()
166 c->cmd = c->mstate.commands[j].cmd; in execCommand()
173 if (!must_propagate && !(c->cmd->flags & (CMD_READONLY|CMD_ADMIN))) { in execCommand()
174 execCommandPropagateMulti(c); in execCommand()
178 call(c,server.loading ? CMD_CALL_NONE : CMD_CALL_FULL); in execCommand()
181 c->mstate.commands[j].argc = c->argc; in execCommand()
182 c->mstate.commands[j].argv = c->argv; in execCommand()
183 c->mstate.commands[j].cmd = c->cmd; in execCommand()
185 c->argv = orig_argv; in execCommand()
186 c->argc = orig_argc; in execCommand()
187 c->cmd = orig_cmd; in execCommand()
188 discardTransaction(c); in execCommand()
213 replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc); in execCommand()
234 void watchForKey(client *c, robj *key) { in watchForKey() argument
241 listRewind(c->watched_keys,&li); in watchForKey()
244 if (wk->db == c->db && equalStringObjects(key,wk->key)) in watchForKey()
248 clients = dictFetchValue(c->db->watched_keys,key); in watchForKey()
251 dictAdd(c->db->watched_keys,key,clients); in watchForKey()
254 listAddNodeTail(clients,c); in watchForKey()
258 wk->db = c->db; in watchForKey()
260 listAddNodeTail(c->watched_keys,wk); in watchForKey()
265 void unwatchAllKeys(client *c) { in unwatchAllKeys() argument
269 if (listLength(c->watched_keys) == 0) return; in unwatchAllKeys()
270 listRewind(c->watched_keys,&li); in unwatchAllKeys()
279 serverAssertWithInfo(c,NULL,clients != NULL); in unwatchAllKeys()
280 listDelNode(clients,listSearchKey(clients,c)); in unwatchAllKeys()
285 listDelNode(c->watched_keys,ln); in unwatchAllKeys()
306 client *c = listNodeValue(ln); in touchWatchedKey() local
308 c->flags |= CLIENT_DIRTY_CAS; in touchWatchedKey()
323 client *c = listNodeValue(ln); in touchWatchedKeysOnFlush() local
324 listRewind(c->watched_keys,&li2); in touchWatchedKeysOnFlush()
333 c->flags |= CLIENT_DIRTY_CAS; in touchWatchedKeysOnFlush()
339 void watchCommand(client *c) { in watchCommand() argument
342 if (c->flags & CLIENT_MULTI) { in watchCommand()
343 addReplyError(c,"WATCH inside MULTI is not allowed"); in watchCommand()
346 for (j = 1; j < c->argc; j++) in watchCommand()
347 watchForKey(c,c->argv[j]); in watchCommand()
348 addReply(c,shared.ok); in watchCommand()
351 void unwatchCommand(client *c) { in unwatchCommand() argument
352 unwatchAllKeys(c); in unwatchCommand()
353 c->flags &= (~CLIENT_DIRTY_CAS); in unwatchCommand()
354 addReply(c,shared.ok); in unwatchCommand()