Commit 554bd0e7 authored by antirez's avatar antirez
Browse files

RDMF: use client instead of redisClient, like Disque.

parent 424fe9af
...@@ -550,8 +550,8 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a ...@@ -550,8 +550,8 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
/* In Redis commands are always executed in the context of a client, so in /* In Redis commands are always executed in the context of a client, so in
* order to load the append only file we need to create a fake client. */ * order to load the append only file we need to create a fake client. */
struct redisClient *createFakeClient(void) { struct client *createFakeClient(void) {
struct redisClient *c = zmalloc(sizeof(*c)); struct client *c = zmalloc(sizeof(*c));
selectDb(c,0); selectDb(c,0);
c->fd = -1; c->fd = -1;
...@@ -577,7 +577,7 @@ struct redisClient *createFakeClient(void) { ...@@ -577,7 +577,7 @@ struct redisClient *createFakeClient(void) {
return c; return c;
} }
void freeFakeClientArgv(struct redisClient *c) { void freeFakeClientArgv(struct client *c) {
int j; int j;
for (j = 0; j < c->argc; j++) for (j = 0; j < c->argc; j++)
...@@ -585,7 +585,7 @@ void freeFakeClientArgv(struct redisClient *c) { ...@@ -585,7 +585,7 @@ void freeFakeClientArgv(struct redisClient *c) {
zfree(c->argv); zfree(c->argv);
} }
void freeFakeClient(struct redisClient *c) { void freeFakeClient(struct client *c) {
sdsfree(c->querybuf); sdsfree(c->querybuf);
listRelease(c->reply); listRelease(c->reply);
listRelease(c->watched_keys); listRelease(c->watched_keys);
...@@ -597,7 +597,7 @@ void freeFakeClient(struct redisClient *c) { ...@@ -597,7 +597,7 @@ void freeFakeClient(struct redisClient *c) {
* error (the append only file is zero-length) REDIS_ERR is returned. On * error (the append only file is zero-length) REDIS_ERR is returned. On
* fatal error an error message is logged and the program exists. */ * fatal error an error message is logged and the program exists. */
int loadAppendOnlyFile(char *filename) { int loadAppendOnlyFile(char *filename) {
struct redisClient *fakeClient; struct client *fakeClient;
FILE *fp = fopen(filename,"r"); FILE *fp = fopen(filename,"r");
struct redis_stat sb; struct redis_stat sb;
int old_aof_state = server.aof_state; int old_aof_state = server.aof_state;
...@@ -1297,7 +1297,7 @@ int rewriteAppendOnlyFileBackground(void) { ...@@ -1297,7 +1297,7 @@ int rewriteAppendOnlyFileBackground(void) {
return REDIS_OK; /* unreached */ return REDIS_OK; /* unreached */
} }
void bgrewriteaofCommand(redisClient *c) { void bgrewriteaofCommand(client *c) {
if (server.aof_child_pid != -1) { if (server.aof_child_pid != -1) {
addReplyError(c,"Background append only file rewriting already in progress"); addReplyError(c,"Background append only file rewriting already in progress");
} else if (server.rdb_child_pid != -1) { } else if (server.rdb_child_pid != -1) {
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
/* This helper function used by GETBIT / SETBIT parses the bit offset argument /* This helper function used by GETBIT / SETBIT parses the bit offset argument
* making sure an error is returned if it is negative or if it overflows * making sure an error is returned if it is negative or if it overflows
* Redis 512 MB limit for the string value. */ * Redis 512 MB limit for the string value. */
static int getBitOffsetFromArgument(redisClient *c, robj *o, size_t *offset) { static int getBitOffsetFromArgument(client *c, robj *o, size_t *offset) {
long long loffset; long long loffset;
char *err = "bit offset is not an integer or out of range"; char *err = "bit offset is not an integer or out of range";
...@@ -209,7 +209,7 @@ long redisBitpos(void *s, unsigned long count, int bit) { ...@@ -209,7 +209,7 @@ long redisBitpos(void *s, unsigned long count, int bit) {
#define BITOP_NOT 3 #define BITOP_NOT 3
/* SETBIT key offset bitvalue */ /* SETBIT key offset bitvalue */
void setbitCommand(redisClient *c) { void setbitCommand(client *c) {
robj *o; robj *o;
char *err = "bit is not an integer or out of range"; char *err = "bit is not an integer or out of range";
size_t bitoffset; size_t bitoffset;
...@@ -256,7 +256,7 @@ void setbitCommand(redisClient *c) { ...@@ -256,7 +256,7 @@ void setbitCommand(redisClient *c) {
} }
/* GETBIT key offset */ /* GETBIT key offset */
void getbitCommand(redisClient *c) { void getbitCommand(client *c) {
robj *o; robj *o;
char llbuf[32]; char llbuf[32];
size_t bitoffset; size_t bitoffset;
...@@ -283,7 +283,7 @@ void getbitCommand(redisClient *c) { ...@@ -283,7 +283,7 @@ void getbitCommand(redisClient *c) {
} }
/* BITOP op_name target_key src_key1 src_key2 src_key3 ... src_keyN */ /* BITOP op_name target_key src_key1 src_key2 src_key3 ... src_keyN */
void bitopCommand(redisClient *c) { void bitopCommand(client *c) {
char *opname = c->argv[1]->ptr; char *opname = c->argv[1]->ptr;
robj *o, *targetkey = c->argv[2]; robj *o, *targetkey = c->argv[2];
unsigned long op, j, numkeys; unsigned long op, j, numkeys;
...@@ -457,7 +457,7 @@ void bitopCommand(redisClient *c) { ...@@ -457,7 +457,7 @@ void bitopCommand(redisClient *c) {
} }
/* BITCOUNT key [start end] */ /* BITCOUNT key [start end] */
void bitcountCommand(redisClient *c) { void bitcountCommand(client *c) {
robj *o; robj *o;
long start, end, strlen; long start, end, strlen;
unsigned char *p; unsigned char *p;
...@@ -511,7 +511,7 @@ void bitcountCommand(redisClient *c) { ...@@ -511,7 +511,7 @@ void bitcountCommand(redisClient *c) {
} }
/* BITPOS key bit [start [end]] */ /* BITPOS key bit [start [end]] */
void bitposCommand(redisClient *c) { void bitposCommand(client *c) {
robj *o; robj *o;
long bit, start, end, strlen; long bit, start, end, strlen;
unsigned char *p; unsigned char *p;
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
* Note that if the timeout is zero (usually from the point of view of * Note that if the timeout is zero (usually from the point of view of
* commands API this means no timeout) the value stored into 'timeout' * commands API this means no timeout) the value stored into 'timeout'
* is zero. */ * is zero. */
int getTimeoutFromObjectOrReply(redisClient *c, robj *object, mstime_t *timeout, int unit) { int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int unit) {
long long tval; long long tval;
if (getLongLongFromObjectOrReply(c,object,&tval, if (getLongLongFromObjectOrReply(c,object,&tval,
...@@ -97,7 +97,7 @@ int getTimeoutFromObjectOrReply(redisClient *c, robj *object, mstime_t *timeout, ...@@ -97,7 +97,7 @@ int getTimeoutFromObjectOrReply(redisClient *c, robj *object, mstime_t *timeout,
/* Block a client for the specific operation type. Once the REDIS_BLOCKED /* Block a client for the specific operation type. Once the REDIS_BLOCKED
* flag is set client query buffer is not longer processed, but accumulated, * flag is set client query buffer is not longer processed, but accumulated,
* and will be processed when the client is unblocked. */ * and will be processed when the client is unblocked. */
void blockClient(redisClient *c, int btype) { void blockClient(client *c, int btype) {
c->flags |= REDIS_BLOCKED; c->flags |= REDIS_BLOCKED;
c->btype = btype; c->btype = btype;
server.bpop_blocked_clients++; server.bpop_blocked_clients++;
...@@ -108,7 +108,7 @@ void blockClient(redisClient *c, int btype) { ...@@ -108,7 +108,7 @@ void blockClient(redisClient *c, int btype) {
* unblocked after a blocking operation. */ * unblocked after a blocking operation. */
void processUnblockedClients(void) { void processUnblockedClients(void) {
listNode *ln; listNode *ln;
redisClient *c; client *c;
while (listLength(server.unblocked_clients)) { while (listLength(server.unblocked_clients)) {
ln = listFirst(server.unblocked_clients); ln = listFirst(server.unblocked_clients);
...@@ -131,7 +131,7 @@ void processUnblockedClients(void) { ...@@ -131,7 +131,7 @@ void processUnblockedClients(void) {
/* Unblock a client calling the right function depending on the kind /* Unblock a client calling the right function depending on the kind
* of operation the client is blocking for. */ * of operation the client is blocking for. */
void unblockClient(redisClient *c) { void unblockClient(client *c) {
if (c->btype == REDIS_BLOCKED_LIST) { if (c->btype == REDIS_BLOCKED_LIST) {
unblockClientWaitingData(c); unblockClientWaitingData(c);
} else if (c->btype == REDIS_BLOCKED_WAIT) { } else if (c->btype == REDIS_BLOCKED_WAIT) {
...@@ -154,7 +154,7 @@ void unblockClient(redisClient *c) { ...@@ -154,7 +154,7 @@ void unblockClient(redisClient *c) {
/* This function gets called when a blocked client timed out in order to /* This function gets called when a blocked client timed out in order to
* send it a reply of some kind. */ * send it a reply of some kind. */
void replyToBlockedClientTimedOut(redisClient *c) { void replyToBlockedClientTimedOut(client *c) {
if (c->btype == REDIS_BLOCKED_LIST) { if (c->btype == REDIS_BLOCKED_LIST) {
addReply(c,shared.nullmultibulk); addReply(c,shared.nullmultibulk);
} else if (c->btype == REDIS_BLOCKED_WAIT) { } else if (c->btype == REDIS_BLOCKED_WAIT) {
...@@ -177,7 +177,7 @@ void disconnectAllBlockedClients(void) { ...@@ -177,7 +177,7 @@ void disconnectAllBlockedClients(void) {
listRewind(server.clients,&li); listRewind(server.clients,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *c = listNodeValue(ln); client *c = listNodeValue(ln);
if (c->flags & REDIS_BLOCKED) { if (c->flags & REDIS_BLOCKED) {
addReplySds(c,sdsnew( addReplySds(c,sdsnew(
......
...@@ -3722,7 +3722,7 @@ sds clusterGenNodesDescription(int filter) { ...@@ -3722,7 +3722,7 @@ sds clusterGenNodesDescription(int filter) {
* CLUSTER command * CLUSTER command
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
int getSlotOrReply(redisClient *c, robj *o) { int getSlotOrReply(client *c, robj *o) {
long long slot; long long slot;
if (getLongLongFromObject(o,&slot) != REDIS_OK || if (getLongLongFromObject(o,&slot) != REDIS_OK ||
...@@ -3734,7 +3734,7 @@ int getSlotOrReply(redisClient *c, robj *o) { ...@@ -3734,7 +3734,7 @@ int getSlotOrReply(redisClient *c, robj *o) {
return (int) slot; return (int) slot;
} }
void clusterReplyMultiBulkSlots(redisClient *c) { void clusterReplyMultiBulkSlots(client *c) {
/* Format: 1) 1) start slot /* Format: 1) 1) start slot
* 2) end slot * 2) end slot
* 3) 1) master IP * 3) 1) master IP
...@@ -3804,7 +3804,7 @@ void clusterReplyMultiBulkSlots(redisClient *c) { ...@@ -3804,7 +3804,7 @@ void clusterReplyMultiBulkSlots(redisClient *c) {
setDeferredMultiBulkLength(c, slot_replylen, num_masters); setDeferredMultiBulkLength(c, slot_replylen, num_masters);
} }
void clusterCommand(redisClient *c) { void clusterCommand(client *c) {
if (server.cluster_enabled == 0) { if (server.cluster_enabled == 0) {
addReplyError(c,"This instance has cluster support disabled"); addReplyError(c,"This instance has cluster support disabled");
return; return;
...@@ -4363,7 +4363,7 @@ int verifyDumpPayload(unsigned char *p, size_t len) { ...@@ -4363,7 +4363,7 @@ int verifyDumpPayload(unsigned char *p, size_t len) {
/* DUMP keyname /* DUMP keyname
* DUMP is actually not used by Redis Cluster but it is the obvious * DUMP is actually not used by Redis Cluster but it is the obvious
* complement of RESTORE and can be useful for different applications. */ * complement of RESTORE and can be useful for different applications. */
void dumpCommand(redisClient *c) { void dumpCommand(client *c) {
robj *o, *dumpobj; robj *o, *dumpobj;
rio payload; rio payload;
...@@ -4384,7 +4384,7 @@ void dumpCommand(redisClient *c) { ...@@ -4384,7 +4384,7 @@ void dumpCommand(redisClient *c) {
} }
/* RESTORE key ttl serialized-value [REPLACE] */ /* RESTORE key ttl serialized-value [REPLACE] */
void restoreCommand(redisClient *c) { void restoreCommand(client *c) {
long long ttl; long long ttl;
rio payload; rio payload;
int j, type, replace = 0; int j, type, replace = 0;
...@@ -4466,7 +4466,7 @@ typedef struct migrateCachedSocket { ...@@ -4466,7 +4466,7 @@ typedef struct migrateCachedSocket {
* If the caller detects an error while using the socket, migrateCloseSocket() * If the caller detects an error while using the socket, migrateCloseSocket()
* should be called so that the connection will be created from scratch * should be called so that the connection will be created from scratch
* the next time. */ * the next time. */
migrateCachedSocket* migrateGetSocket(redisClient *c, robj *host, robj *port, long timeout) { migrateCachedSocket* migrateGetSocket(client *c, robj *host, robj *port, long timeout) {
int fd; int fd;
sds name = sdsempty(); sds name = sdsempty();
migrateCachedSocket *cs; migrateCachedSocket *cs;
...@@ -4558,7 +4558,7 @@ void migrateCloseTimedoutSockets(void) { ...@@ -4558,7 +4558,7 @@ void migrateCloseTimedoutSockets(void) {
} }
/* MIGRATE host port key dbid timeout [COPY | REPLACE] */ /* MIGRATE host port key dbid timeout [COPY | REPLACE] */
void migrateCommand(redisClient *c) { void migrateCommand(client *c) {
migrateCachedSocket *cs; migrateCachedSocket *cs;
int copy, replace, j; int copy, replace, j;
long timeout; long timeout;
...@@ -4723,7 +4723,7 @@ socket_rd_err: ...@@ -4723,7 +4723,7 @@ socket_rd_err:
* The client should issue ASKING before to actually send the command to * The client should issue ASKING before to actually send the command to
* the target instance. See the Redis Cluster specification for more * the target instance. See the Redis Cluster specification for more
* information. */ * information. */
void askingCommand(redisClient *c) { void askingCommand(client *c) {
if (server.cluster_enabled == 0) { if (server.cluster_enabled == 0) {
addReplyError(c,"This instance has cluster support disabled"); addReplyError(c,"This instance has cluster support disabled");
return; return;
...@@ -4735,7 +4735,7 @@ void askingCommand(redisClient *c) { ...@@ -4735,7 +4735,7 @@ void askingCommand(redisClient *c) {
/* The READONLY command is used by clients to enter the read-only mode. /* The READONLY command is used by clients to enter the read-only mode.
* In this mode slaves will not redirect clients as long as clients access * In this mode slaves will not redirect clients as long as clients access
* with read-only commands to keys that are served by the slave's master. */ * with read-only commands to keys that are served by the slave's master. */
void readonlyCommand(redisClient *c) { void readonlyCommand(client *c) {
if (server.cluster_enabled == 0) { if (server.cluster_enabled == 0) {
addReplyError(c,"This instance has cluster support disabled"); addReplyError(c,"This instance has cluster support disabled");
return; return;
...@@ -4745,7 +4745,7 @@ void readonlyCommand(redisClient *c) { ...@@ -4745,7 +4745,7 @@ void readonlyCommand(redisClient *c) {
} }
/* The READWRITE command just clears the READONLY command state. */ /* The READWRITE command just clears the READONLY command state. */
void readwriteCommand(redisClient *c) { void readwriteCommand(client *c) {
c->flags &= ~REDIS_READONLY; c->flags &= ~REDIS_READONLY;
addReply(c,shared.ok); addReply(c,shared.ok);
} }
...@@ -4779,7 +4779,7 @@ void readwriteCommand(redisClient *c) { ...@@ -4779,7 +4779,7 @@ void readwriteCommand(redisClient *c) {
* not bound to any node. In this case the cluster global state should be * not bound to any node. In this case the cluster global state should be
* already "down" but it is fragile to rely on the update of the global state, * already "down" but it is fragile to rely on the update of the global state,
* so we also handle it here. */ * so we also handle it here. */
clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) { clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) {
clusterNode *n = NULL; clusterNode *n = NULL;
robj *firstkey = NULL; robj *firstkey = NULL;
int multiple_keys = 0; int multiple_keys = 0;
...@@ -4940,7 +4940,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg ...@@ -4940,7 +4940,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg
* are used, then the node 'n' should not be NULL, but should be the * are used, then the node 'n' should not be NULL, but should be the
* node we want to mention in the redirection. Moreover hashslot should * node we want to mention in the redirection. Moreover hashslot should
* be set to the hash slot that caused the redirection. */ * be set to the hash slot that caused the redirection. */
void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int error_code) { void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code) {
if (error_code == REDIS_CLUSTER_REDIR_CROSS_SLOT) { if (error_code == REDIS_CLUSTER_REDIR_CROSS_SLOT) {
addReplySds(c,sdsnew("-CROSSSLOT Keys in request don't hash to the same slot\r\n")); addReplySds(c,sdsnew("-CROSSSLOT Keys in request don't hash to the same slot\r\n"));
} else if (error_code == REDIS_CLUSTER_REDIR_UNSTABLE) { } else if (error_code == REDIS_CLUSTER_REDIR_UNSTABLE) {
...@@ -4975,7 +4975,7 @@ void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int err ...@@ -4975,7 +4975,7 @@ void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int err
* If the client is found to be blocked into an hash slot this node no * If the client is found to be blocked into an hash slot this node no
* longer handles, the client is sent a redirection error, and the function * longer handles, the client is sent a redirection error, and the function
* returns 1. Otherwise 0 is returned and no operation is performed. */ * returns 1. Otherwise 0 is returned and no operation is performed. */
int clusterRedirectBlockedClientIfNeeded(redisClient *c) { int clusterRedirectBlockedClientIfNeeded(client *c) {
if (c->flags & REDIS_BLOCKED && c->btype == REDIS_BLOCKED_LIST) { if (c->flags & REDIS_BLOCKED && c->btype == REDIS_BLOCKED_LIST) {
dictEntry *de; dictEntry *de;
dictIterator *di; dictIterator *di;
......
...@@ -249,8 +249,8 @@ typedef struct { ...@@ -249,8 +249,8 @@ typedef struct {
master is up. */ master is up. */
/* ---------------------- API exported outside cluster.c -------------------- */ /* ---------------------- API exported outside cluster.c -------------------- */
clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask); clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
int clusterRedirectBlockedClientIfNeeded(redisClient *c); int clusterRedirectBlockedClientIfNeeded(client *c);
void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int error_code); void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
#endif /* __REDIS_CLUSTER_H */ #endif /* __REDIS_CLUSTER_H */
...@@ -699,7 +699,7 @@ void loadServerConfig(char *filename, char *options) { ...@@ -699,7 +699,7 @@ void loadServerConfig(char *filename, char *options) {
#define config_set_else } else #define config_set_else } else
void configSetCommand(redisClient *c) { void configSetCommand(client *c) {
robj *o; robj *o;
long long ll; long long ll;
int err; int err;
...@@ -1024,7 +1024,7 @@ badfmt: /* Bad format errors */ ...@@ -1024,7 +1024,7 @@ badfmt: /* Bad format errors */
} \ } \
} while(0); } while(0);
void configGetCommand(redisClient *c) { void configGetCommand(client *c) {
robj *o = c->argv[2]; robj *o = c->argv[2];
void *replylen = addDeferredMultiBulkLength(c); void *replylen = addDeferredMultiBulkLength(c);
char *pattern = o->ptr; char *pattern = o->ptr;
...@@ -1843,7 +1843,7 @@ int rewriteConfig(char *path) { ...@@ -1843,7 +1843,7 @@ int rewriteConfig(char *path) {
* CONFIG command entry point * CONFIG command entry point
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void configCommand(redisClient *c) { void configCommand(client *c) {
if (!strcasecmp(c->argv[1]->ptr,"set")) { if (!strcasecmp(c->argv[1]->ptr,"set")) {
if (c->argc != 4) goto badarity; if (c->argc != 4) goto badarity;
configSetCommand(c); configSetCommand(c);
......
...@@ -99,13 +99,13 @@ robj *lookupKeyWrite(redisDb *db, robj *key) { ...@@ -99,13 +99,13 @@ robj *lookupKeyWrite(redisDb *db, robj *key) {
return lookupKey(db,key); return lookupKey(db,key);
} }
robj *lookupKeyReadOrReply(redisClient *c, robj *key, robj *reply) { robj *lookupKeyReadOrReply(client *c, robj *key, robj *reply) {
robj *o = lookupKeyRead(c->db, key); robj *o = lookupKeyRead(c->db, key);
if (!o) addReply(c,reply); if (!o) addReply(c,reply);
return o; return o;
} }
robj *lookupKeyWriteOrReply(redisClient *c, robj *key, robj *reply) { robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply) {
robj *o = lookupKeyWrite(c->db, key); robj *o = lookupKeyWrite(c->db, key);
if (!o) addReply(c,reply); if (!o) addReply(c,reply);
return o; return o;
...@@ -247,7 +247,7 @@ long long emptyDb(void(callback)(void*)) { ...@@ -247,7 +247,7 @@ long long emptyDb(void(callback)(void*)) {
return removed; return removed;
} }
int selectDb(redisClient *c, int id) { int selectDb(client *c, int id) {
if (id < 0 || id >= server.dbnum) if (id < 0 || id >= server.dbnum)
return REDIS_ERR; return REDIS_ERR;
c->db = &server.db[id]; c->db = &server.db[id];
...@@ -275,7 +275,7 @@ void signalFlushedDb(int dbid) { ...@@ -275,7 +275,7 @@ void signalFlushedDb(int dbid) {
* Type agnostic commands operating on the key space * Type agnostic commands operating on the key space
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void flushdbCommand(redisClient *c) { void flushdbCommand(client *c) {
server.dirty += dictSize(c->db->dict); server.dirty += dictSize(c->db->dict);
signalFlushedDb(c->db->id); signalFlushedDb(c->db->id);
dictEmpty(c->db->dict,NULL); dictEmpty(c->db->dict,NULL);
...@@ -284,7 +284,7 @@ void flushdbCommand(redisClient *c) { ...@@ -284,7 +284,7 @@ void flushdbCommand(redisClient *c) {
addReply(c,shared.ok); addReply(c,shared.ok);
} }
void flushallCommand(redisClient *c) { void flushallCommand(client *c) {
signalFlushedDb(-1); signalFlushedDb(-1);
server.dirty += emptyDb(NULL); server.dirty += emptyDb(NULL);
addReply(c,shared.ok); addReply(c,shared.ok);
...@@ -302,7 +302,7 @@ void flushallCommand(redisClient *c) { ...@@ -302,7 +302,7 @@ void flushallCommand(redisClient *c) {
server.dirty++; server.dirty++;
} }
void delCommand(redisClient *c) { void delCommand(client *c) {
int deleted = 0, j; int deleted = 0, j;
for (j = 1; j < c->argc; j++) { for (j = 1; j < c->argc; j++) {
...@@ -320,7 +320,7 @@ void delCommand(redisClient *c) { ...@@ -320,7 +320,7 @@ void delCommand(redisClient *c) {
/* EXISTS key1 key2 ... key_N. /* EXISTS key1 key2 ... key_N.
* Return value is the number of keys existing. */ * Return value is the number of keys existing. */
void existsCommand(redisClient *c) { void existsCommand(client *c) {
long long count = 0; long long count = 0;
int j; int j;
...@@ -331,7 +331,7 @@ void existsCommand(redisClient *c) { ...@@ -331,7 +331,7 @@ void existsCommand(redisClient *c) {
addReplyLongLong(c,count); addReplyLongLong(c,count);
} }
void selectCommand(redisClient *c) { void selectCommand(client *c) {
long id; long id;
if (getLongFromObjectOrReply(c, c->argv[1], &id, if (getLongFromObjectOrReply(c, c->argv[1], &id,
...@@ -349,7 +349,7 @@ void selectCommand(redisClient *c) { ...@@ -349,7 +349,7 @@ void selectCommand(redisClient *c) {
} }
} }
void randomkeyCommand(redisClient *c) { void randomkeyCommand(client *c) {
robj *key; robj *key;
if ((key = dbRandomKey(c->db)) == NULL) { if ((key = dbRandomKey(c->db)) == NULL) {
...@@ -361,7 +361,7 @@ void randomkeyCommand(redisClient *c) { ...@@ -361,7 +361,7 @@ void randomkeyCommand(redisClient *c) {
decrRefCount(key); decrRefCount(key);
} }
void keysCommand(redisClient *c) { void keysCommand(client *c) {
dictIterator *di; dictIterator *di;
dictEntry *de; dictEntry *de;
sds pattern = c->argv[1]->ptr; sds pattern = c->argv[1]->ptr;
...@@ -423,7 +423,7 @@ void scanCallback(void *privdata, const dictEntry *de) { ...@@ -423,7 +423,7 @@ void scanCallback(void *privdata, const dictEntry *de) {
* if the cursor is valid, store it as unsigned integer into *cursor and * if the cursor is valid, store it as unsigned integer into *cursor and
* returns REDIS_OK. Otherwise return REDIS_ERR and send an error to the * returns REDIS_OK. Otherwise return REDIS_ERR and send an error to the
* client. */ * client. */
int parseScanCursorOrReply(redisClient *c, robj *o, unsigned long *cursor) { int parseScanCursorOrReply(client *c, robj *o, unsigned long *cursor) {
char *eptr; char *eptr;
/* Use strtoul() because we need an *unsigned* long, so /* Use strtoul() because we need an *unsigned* long, so
...@@ -449,7 +449,7 @@ int parseScanCursorOrReply(redisClient *c, robj *o, unsigned long *cursor) { ...@@ -449,7 +449,7 @@ int parseScanCursorOrReply(redisClient *c, robj *o, unsigned long *cursor) {
* *
* In the case of a Hash object the function returns both the field and value * In the case of a Hash object the function returns both the field and value
* of every element on the Hash. */ * of every element on the Hash. */
void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) { void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
int i, j; int i, j;
list *keys = listCreate(); list *keys = listCreate();
listNode *node, *nextnode; listNode *node, *nextnode;
...@@ -627,21 +627,21 @@ cleanup: ...@@ -627,21 +627,21 @@ cleanup:
} }
/* The SCAN command completely relies on scanGenericCommand. */ /* The SCAN command completely relies on scanGenericCommand. */
void scanCommand(redisClient *c) { void scanCommand(client *c) {
unsigned long cursor; unsigned long cursor;
if (parseScanCursorOrReply(c,c->argv[1],&cursor) == REDIS_ERR) return; if (parseScanCursorOrReply(c,c->argv[1],&cursor) == REDIS_ERR) return;
scanGenericCommand(c,NULL,cursor); scanGenericCommand(c,NULL,cursor);
} }
void dbsizeCommand(redisClient *c) { void dbsizeCommand(client *c) {
addReplyLongLong(c,dictSize(c->db->dict)); addReplyLongLong(c,dictSize(c->db->dict));
} }
void lastsaveCommand(redisClient *c) { void lastsaveCommand(client *c) {
addReplyLongLong(c,server.lastsave); addReplyLongLong(c,server.lastsave);
} }
void typeCommand(redisClient *c) { void typeCommand(client *c) {
robj *o; robj *o;
char *type; char *type;
...@@ -661,7 +661,7 @@ void typeCommand(redisClient *c) { ...@@ -661,7 +661,7 @@ void typeCommand(redisClient *c) {
addReplyStatus(c,type); addReplyStatus(c,type);
} }
void shutdownCommand(redisClient *c) { void shutdownCommand(client *c) {
int flags = 0; int flags = 0;
if (c->argc > 2) { if (c->argc > 2) {
...@@ -689,7 +689,7 @@ void shutdownCommand(redisClient *c) { ...@@ -689,7 +689,7 @@ void shutdownCommand(redisClient *c) {
addReplyError(c,"Errors trying to SHUTDOWN. Check logs."); addReplyError(c,"Errors trying to SHUTDOWN. Check logs.");
} }
void renameGenericCommand(redisClient *c, int nx) { void renameGenericCommand(client *c, int nx) {
robj *o; robj *o;
long long expire; long long expire;
int samekey = 0; int samekey = 0;
...@@ -731,15 +731,15 @@ void renameGenericCommand(redisClient *c, int nx) { ...@@ -731,15 +731,15 @@ void renameGenericCommand(redisClient *c, int nx) {
addReply(c,nx ? shared.cone : shared.ok); addReply(c,nx ? shared.cone : shared.ok);
} }
void renameCommand(redisClient *c) { void renameCommand(client *c) {
renameGenericCommand(c,0); renameGenericCommand(c,0);
} }
void renamenxCommand(redisClient *c) { void renamenxCommand(client *c) {
renameGenericCommand(c,1); renameGenericCommand(c,1);
} }
void moveCommand(redisClient *c) { void moveCommand(client *c) {
robj *o; robj *o;
redisDb *src, *dst; redisDb *src, *dst;
int srcid; int srcid;
...@@ -899,7 +899,7 @@ int expireIfNeeded(redisDb *db, robj *key) { ...@@ -899,7 +899,7 @@ int expireIfNeeded(redisDb *db, robj *key) {
* *
* unit is either UNIT_SECONDS or UNIT_MILLISECONDS, and is only used for * unit is either UNIT_SECONDS or UNIT_MILLISECONDS, and is only used for
* the argv[2] parameter. The basetime is always specified in milliseconds. */ * the argv[2] parameter. The basetime is always specified in milliseconds. */
void expireGenericCommand(redisClient *c, long long basetime, int unit) { void expireGenericCommand(client *c, long long basetime, int unit) {
robj *key = c->argv[1], *param = c->argv[2]; robj *key = c->argv[1], *param = c->argv[2];
long long when; /* unix time in milliseconds when the key will expire. */ long long when; /* unix time in milliseconds when the key will expire. */
...@@ -945,23 +945,23 @@ void expireGenericCommand(redisClient *c, long long basetime, int unit) { ...@@ -945,23 +945,23 @@ void expireGenericCommand(redisClient *c, long long basetime, int unit) {
} }
} }
void expireCommand(redisClient *c) { void expireCommand(client *c) {
expireGenericCommand(c,mstime(),UNIT_SECONDS); expireGenericCommand(c,mstime(),UNIT_SECONDS);
} }
void expireatCommand(redisClient *c) { void expireatCommand(client *c) {
expireGenericCommand(c,0,UNIT_SECONDS); expireGenericCommand(c,0,UNIT_SECONDS);
} }
void pexpireCommand(redisClient *c) { void pexpireCommand(client *c) {
expireGenericCommand(c,mstime(),UNIT_MILLISECONDS); expireGenericCommand(c,mstime(),UNIT_MILLISECONDS);
} }
void pexpireatCommand(redisClient *c) { void pexpireatCommand(client *c) {
expireGenericCommand(c,0,UNIT_MILLISECONDS); expireGenericCommand(c,0,UNIT_MILLISECONDS);
} }
void ttlGenericCommand(redisClient *c, int output_ms) { void ttlGenericCommand(client *c, int output_ms) {
long long expire, ttl = -1; long long expire, ttl = -1;
/* If the key does not exist at all, return -2 */ /* If the key does not exist at all, return -2 */
...@@ -983,15 +983,15 @@ void ttlGenericCommand(redisClient *c, int output_ms) { ...@@ -983,15 +983,15 @@ void ttlGenericCommand(redisClient *c, int output_ms) {
} }
} }
void ttlCommand(redisClient *c) { void ttlCommand(client *c) {
ttlGenericCommand(c, 0); ttlGenericCommand(c, 0);
} }
void pttlCommand(redisClient *c) { void pttlCommand(client *c) {
ttlGenericCommand(c, 1); ttlGenericCommand(c, 1);
} }
void persistCommand(redisClient *c) { void persistCommand(client *c) {
dictEntry *de; dictEntry *de;
de = dictFind(c->db->dict,c->argv[1]->ptr); de = dictFind(c->db->dict,c->argv[1]->ptr);
......
...@@ -258,7 +258,7 @@ void inputCatSds(void *result, const char *str) { ...@@ -258,7 +258,7 @@ void inputCatSds(void *result, const char *str) {
*info = sdscat(*info, str); *info = sdscat(*info, str);
} }
void debugCommand(redisClient *c) { void debugCommand(client *c) {
if (!strcasecmp(c->argv[1]->ptr,"segfault")) { if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
*((char*)-1) = 'x'; *((char*)-1) = 'x';
} else if (!strcasecmp(c->argv[1]->ptr,"oom")) { } else if (!strcasecmp(c->argv[1]->ptr,"oom")) {
...@@ -483,7 +483,7 @@ void _redisAssert(char *estr, char *file, int line) { ...@@ -483,7 +483,7 @@ void _redisAssert(char *estr, char *file, int line) {
*((char*)-1) = 'x'; *((char*)-1) = 'x';
} }
void _redisAssertPrintClientInfo(redisClient *c) { void _redisAssertPrintClientInfo(client *c) {
int j; int j;
bugReportStart(); bugReportStart();
...@@ -537,7 +537,7 @@ void _redisAssertPrintObject(robj *o) { ...@@ -537,7 +537,7 @@ void _redisAssertPrintObject(robj *o) {
serverLogObjectDebugInfo(o); serverLogObjectDebugInfo(o);
} }
void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int line) { void _redisAssertWithInfo(client *c, robj *o, char *estr, char *file, int line) {
if (c) _redisAssertPrintClientInfo(c); if (c) _redisAssertPrintClientInfo(c);
if (o) _redisAssertPrintObject(o); if (o) _redisAssertPrintObject(o);
_redisAssert(estr,file,line); _redisAssert(estr,file,line);
...@@ -770,7 +770,7 @@ void logStackTrace(ucontext_t *uc) { ...@@ -770,7 +770,7 @@ void logStackTrace(ucontext_t *uc) {
void logCurrentClient(void) { void logCurrentClient(void) {
if (server.current_client == NULL) return; if (server.current_client == NULL) return;
redisClient *cc = server.current_client; client *cc = server.current_client;
sds client; sds client;
int j; int j;
......
...@@ -89,7 +89,7 @@ int decodeGeohash(double bits, double *xy) { ...@@ -89,7 +89,7 @@ int decodeGeohash(double bits, double *xy) {
/* Input Argument Helper */ /* Input Argument Helper */
/* Take a pointer to the latitude arg then use the next arg for longitude. /* Take a pointer to the latitude arg then use the next arg for longitude.
* On parse error REDIS_ERR is returned, otherwise REDIS_OK. */ * On parse error REDIS_ERR is returned, otherwise REDIS_OK. */
int extractLongLatOrReply(redisClient *c, robj **argv, int extractLongLatOrReply(client *c, robj **argv,
double *xy) { double *xy) {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (getDoubleFromObjectOrReply(c, argv[i], xy + i, NULL) != if (getDoubleFromObjectOrReply(c, argv[i], xy + i, NULL) !=
...@@ -123,7 +123,7 @@ int longLatFromMember(robj *zobj, robj *member, double *xy) { ...@@ -123,7 +123,7 @@ int longLatFromMember(robj *zobj, robj *member, double *xy) {
* *
* If the unit is not valid, an error is reported to the client, and a value * If the unit is not valid, an error is reported to the client, and a value
* less than zero is returned. */ * less than zero is returned. */
double extractUnitOrReply(redisClient *c, robj *unit) { double extractUnitOrReply(client *c, robj *unit) {
char *u = unit->ptr; char *u = unit->ptr;
if (!strcmp(u, "m")) { if (!strcmp(u, "m")) {
...@@ -148,7 +148,7 @@ double extractUnitOrReply(redisClient *c, robj *unit) { ...@@ -148,7 +148,7 @@ double extractUnitOrReply(redisClient *c, robj *unit) {
* to use in order to convert meters to the unit. * to use in order to convert meters to the unit.
* *
* On error a value less than zero is returned. */ * On error a value less than zero is returned. */
double extractDistanceOrReply(redisClient *c, robj **argv, double extractDistanceOrReply(client *c, robj **argv,
double *conversion) { double *conversion) {
double distance; double distance;
if (getDoubleFromObjectOrReply(c, argv[0], &distance, if (getDoubleFromObjectOrReply(c, argv[0], &distance,
...@@ -168,7 +168,7 @@ double extractDistanceOrReply(redisClient *c, robj **argv, ...@@ -168,7 +168,7 @@ double extractDistanceOrReply(redisClient *c, robj **argv,
* than "5.2144992818115 meters away." We provide 4 digits after the dot * than "5.2144992818115 meters away." We provide 4 digits after the dot
* so that the returned value is decently accurate even when the unit is * so that the returned value is decently accurate even when the unit is
* the kilometer. */ * the kilometer. */
void addReplyDoubleDistance(redisClient *c, double d) { void addReplyDoubleDistance(client *c, double d) {
char dbuf[128]; char dbuf[128];
int dlen = snprintf(dbuf, sizeof(dbuf), "%.4f", d); int dlen = snprintf(dbuf, sizeof(dbuf), "%.4f", d);
addReplyBulkCBuffer(c, dbuf, dlen); addReplyBulkCBuffer(c, dbuf, dlen);
...@@ -363,7 +363,7 @@ static int sort_gp_desc(const void *a, const void *b) { ...@@ -363,7 +363,7 @@ static int sort_gp_desc(const void *a, const void *b) {
* ==================================================================== */ * ==================================================================== */
/* GEOADD key long lat name [long2 lat2 name2 ... longN latN nameN] */ /* GEOADD key long lat name [long2 lat2 name2 ... longN latN nameN] */
void geoaddCommand(redisClient *c) { void geoaddCommand(client *c) {
/* Check arguments number for sanity. */ /* Check arguments number for sanity. */
if ((c->argc - 2) % 3 != 0) { if ((c->argc - 2) % 3 != 0) {
/* Need an odd number of arguments if we got this far... */ /* Need an odd number of arguments if we got this far... */
...@@ -419,7 +419,7 @@ void geoaddCommand(redisClient *c) { ...@@ -419,7 +419,7 @@ void geoaddCommand(redisClient *c) {
/* GEORADIUS key x y radius unit [WITHDIST] [WITHHASH] [WITHCOORD] [ASC|DESC] /* GEORADIUS key x y radius unit [WITHDIST] [WITHHASH] [WITHCOORD] [ASC|DESC]
* [COUNT count] * [COUNT count]
* GEORADIUSBYMEMBER key member radius unit ... options ... */ * GEORADIUSBYMEMBER key member radius unit ... options ... */
void georadiusGeneric(redisClient *c, int type) { void georadiusGeneric(client *c, int type) {
robj *key = c->argv[1]; robj *key = c->argv[1];
/* Look up the requested zset */ /* Look up the requested zset */
...@@ -569,12 +569,12 @@ void georadiusGeneric(redisClient *c, int type) { ...@@ -569,12 +569,12 @@ void georadiusGeneric(redisClient *c, int type) {
} }
/* GEORADIUS wrapper function. */ /* GEORADIUS wrapper function. */
void georadiusCommand(redisClient *c) { void georadiusCommand(client *c) {
georadiusGeneric(c, RADIUS_COORDS); georadiusGeneric(c, RADIUS_COORDS);
} }
/* GEORADIUSBYMEMBER wrapper function. */ /* GEORADIUSBYMEMBER wrapper function. */
void georadiusByMemberCommand(redisClient *c) { void georadiusByMemberCommand(client *c) {
georadiusGeneric(c, RADIUS_MEMBER); georadiusGeneric(c, RADIUS_MEMBER);
} }
...@@ -582,7 +582,7 @@ void georadiusByMemberCommand(redisClient *c) { ...@@ -582,7 +582,7 @@ void georadiusByMemberCommand(redisClient *c) {
* *
* Returns an array with an 11 characters geohash representation of the * Returns an array with an 11 characters geohash representation of the
* position of the specified elements. */ * position of the specified elements. */
void geohashCommand(redisClient *c) { void geohashCommand(client *c) {
char *geoalphabet= "0123456789bcdefghjkmnpqrstuvwxyz"; char *geoalphabet= "0123456789bcdefghjkmnpqrstuvwxyz";
int j; int j;
...@@ -637,7 +637,7 @@ void geohashCommand(redisClient *c) { ...@@ -637,7 +637,7 @@ void geohashCommand(redisClient *c) {
* *
* Returns an array of two-items arrays representing the x,y position of each * Returns an array of two-items arrays representing the x,y position of each
* element specified in the arguments. For missing elements NULL is returned. */ * element specified in the arguments. For missing elements NULL is returned. */
void geoposCommand(redisClient *c) { void geoposCommand(client *c) {
int j; int j;
/* Look up the requested zset */ /* Look up the requested zset */
...@@ -671,7 +671,7 @@ void geoposCommand(redisClient *c) { ...@@ -671,7 +671,7 @@ void geoposCommand(redisClient *c) {
* Return the distance, in meters by default, otherwise accordig to "unit", * Return the distance, in meters by default, otherwise accordig to "unit",
* between points ele1 and ele2. If one or more elements are missing NULL * between points ele1 and ele2. If one or more elements are missing NULL
* is returned. */ * is returned. */
void geodistCommand(redisClient *c) { void geodistCommand(client *c) {
double to_meter = 1; double to_meter = 1;
/* Check if there is the unit to extract, otherwise assume meters. */ /* Check if there is the unit to extract, otherwise assume meters. */
......
...@@ -1121,7 +1121,7 @@ robj *createHLLObject(void) { ...@@ -1121,7 +1121,7 @@ robj *createHLLObject(void) {
/* Check if the object is a String with a valid HLL representation. /* Check if the object is a String with a valid HLL representation.
* Return REDIS_OK if this is true, otherwise reply to the client * Return REDIS_OK if this is true, otherwise reply to the client
* with an error and return REDIS_ERR. */ * with an error and return REDIS_ERR. */
int isHLLObjectOrReply(redisClient *c, robj *o) { int isHLLObjectOrReply(client *c, robj *o) {
struct hllhdr *hdr; struct hllhdr *hdr;
/* Key exists, check type */ /* Key exists, check type */
...@@ -1152,7 +1152,7 @@ invalid: ...@@ -1152,7 +1152,7 @@ invalid:
} }
/* PFADD var ele ele ele ... ele => :0 or :1 */ /* PFADD var ele ele ele ... ele => :0 or :1 */
void pfaddCommand(redisClient *c) { void pfaddCommand(client *c) {
robj *o = lookupKeyWrite(c->db,c->argv[1]); robj *o = lookupKeyWrite(c->db,c->argv[1]);
struct hllhdr *hdr; struct hllhdr *hdr;
int updated = 0, j; int updated = 0, j;
...@@ -1192,7 +1192,7 @@ void pfaddCommand(redisClient *c) { ...@@ -1192,7 +1192,7 @@ void pfaddCommand(redisClient *c) {
} }
/* PFCOUNT var -> approximated cardinality of set. */ /* PFCOUNT var -> approximated cardinality of set. */
void pfcountCommand(redisClient *c) { void pfcountCommand(client *c) {
robj *o; robj *o;
struct hllhdr *hdr; struct hllhdr *hdr;
uint64_t card; uint64_t card;
...@@ -1282,7 +1282,7 @@ void pfcountCommand(redisClient *c) { ...@@ -1282,7 +1282,7 @@ void pfcountCommand(redisClient *c) {
} }
/* PFMERGE dest src1 src2 src3 ... srcN => OK */ /* PFMERGE dest src1 src2 src3 ... srcN => OK */
void pfmergeCommand(redisClient *c) { void pfmergeCommand(client *c) {
uint8_t max[HLL_REGISTERS]; uint8_t max[HLL_REGISTERS];
struct hllhdr *hdr; struct hllhdr *hdr;
int j; int j;
...@@ -1348,7 +1348,7 @@ void pfmergeCommand(redisClient *c) { ...@@ -1348,7 +1348,7 @@ void pfmergeCommand(redisClient *c) {
* This command performs a self-test of the HLL registers implementation. * This command performs a self-test of the HLL registers implementation.
* Something that is not easy to test from within the outside. */ * Something that is not easy to test from within the outside. */
#define HLL_TEST_CYCLES 1000 #define HLL_TEST_CYCLES 1000
void pfselftestCommand(redisClient *c) { void pfselftestCommand(client *c) {
unsigned int j, i; unsigned int j, i;
sds bitcounters = sdsnewlen(NULL,HLL_DENSE_SIZE); sds bitcounters = sdsnewlen(NULL,HLL_DENSE_SIZE);
struct hllhdr *hdr = (struct hllhdr*) bitcounters, *hdr2; struct hllhdr *hdr = (struct hllhdr*) bitcounters, *hdr2;
...@@ -1452,7 +1452,7 @@ cleanup: ...@@ -1452,7 +1452,7 @@ cleanup:
/* PFDEBUG <subcommand> <key> ... args ... /* PFDEBUG <subcommand> <key> ... args ...
* Different debugging related operations about the HLL implementation. */ * Different debugging related operations about the HLL implementation. */
void pfdebugCommand(redisClient *c) { void pfdebugCommand(client *c) {
char *cmd = c->argv[1]->ptr; char *cmd = c->argv[1]->ptr;
struct hllhdr *hdr; struct hllhdr *hdr;
robj *o; robj *o;
......
...@@ -474,7 +474,7 @@ sds createLatencyReport(void) { ...@@ -474,7 +474,7 @@ sds createLatencyReport(void) {
/* latencyCommand() helper to produce a time-delay reply for all the samples /* latencyCommand() helper to produce a time-delay reply for all the samples
* in memory for the specified time series. */ * in memory for the specified time series. */
void latencyCommandReplyWithSamples(redisClient *c, struct latencyTimeSeries *ts) { void latencyCommandReplyWithSamples(client *c, struct latencyTimeSeries *ts) {
void *replylen = addDeferredMultiBulkLength(c); void *replylen = addDeferredMultiBulkLength(c);
int samples = 0, j; int samples = 0, j;
...@@ -492,7 +492,7 @@ void latencyCommandReplyWithSamples(redisClient *c, struct latencyTimeSeries *ts ...@@ -492,7 +492,7 @@ void latencyCommandReplyWithSamples(redisClient *c, struct latencyTimeSeries *ts
/* latencyCommand() helper to produce the reply for the LATEST subcommand, /* latencyCommand() helper to produce the reply for the LATEST subcommand,
* listing the last latency sample for every event type registered so far. */ * listing the last latency sample for every event type registered so far. */
void latencyCommandReplyWithLatestEvents(redisClient *c) { void latencyCommandReplyWithLatestEvents(client *c) {
dictIterator *di; dictIterator *di;
dictEntry *de; dictEntry *de;
...@@ -564,7 +564,7 @@ sds latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) { ...@@ -564,7 +564,7 @@ sds latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) {
* LATENCY DOCTOR: returns an human readable analysis of instance latency. * LATENCY DOCTOR: returns an human readable analysis of instance latency.
* LATENCY GRAPH: provide an ASCII graph of the latency of the specified event. * LATENCY GRAPH: provide an ASCII graph of the latency of the specified event.
*/ */
void latencyCommand(redisClient *c) { void latencyCommand(client *c) {
struct latencyTimeSeries *ts; struct latencyTimeSeries *ts;
if (!strcasecmp(c->argv[1]->ptr,"history") && c->argc == 3) { if (!strcasecmp(c->argv[1]->ptr,"history") && c->argc == 3) {
......
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
/* ================================ MULTI/EXEC ============================== */ /* ================================ MULTI/EXEC ============================== */
/* Client state initialization for MULTI/EXEC */ /* Client state initialization for MULTI/EXEC */
void initClientMultiState(redisClient *c) { void initClientMultiState(client *c) {
c->mstate.commands = NULL; c->mstate.commands = NULL;
c->mstate.count = 0; c->mstate.count = 0;
} }
/* Release all the resources associated with MULTI/EXEC state */ /* Release all the resources associated with MULTI/EXEC state */
void freeClientMultiState(redisClient *c) { void freeClientMultiState(client *c) {
int j; int j;
for (j = 0; j < c->mstate.count; j++) { for (j = 0; j < c->mstate.count; j++) {
...@@ -53,7 +53,7 @@ void freeClientMultiState(redisClient *c) { ...@@ -53,7 +53,7 @@ void freeClientMultiState(redisClient *c) {
} }
/* Add a new command into the MULTI commands queue */ /* Add a new command into the MULTI commands queue */
void queueMultiCommand(redisClient *c) { void queueMultiCommand(client *c) {
multiCmd *mc; multiCmd *mc;
int j; int j;
...@@ -69,7 +69,7 @@ void queueMultiCommand(redisClient *c) { ...@@ -69,7 +69,7 @@ void queueMultiCommand(redisClient *c) {
c->mstate.count++; c->mstate.count++;
} }
void discardTransaction(redisClient *c) { void discardTransaction(client *c) {
freeClientMultiState(c); freeClientMultiState(c);
initClientMultiState(c); initClientMultiState(c);
c->flags &= ~(REDIS_MULTI|REDIS_DIRTY_CAS|REDIS_DIRTY_EXEC); c->flags &= ~(REDIS_MULTI|REDIS_DIRTY_CAS|REDIS_DIRTY_EXEC);
...@@ -78,12 +78,12 @@ void discardTransaction(redisClient *c) { ...@@ -78,12 +78,12 @@ void discardTransaction(redisClient *c) {
/* Flag the transacation as DIRTY_EXEC so that EXEC will fail. /* Flag the transacation as DIRTY_EXEC so that EXEC will fail.
* Should be called every time there is an error while queueing a command. */ * Should be called every time there is an error while queueing a command. */
void flagTransaction(redisClient *c) { void flagTransaction(client *c) {
if (c->flags & REDIS_MULTI) if (c->flags & REDIS_MULTI)
c->flags |= REDIS_DIRTY_EXEC; c->flags |= REDIS_DIRTY_EXEC;
} }
void multiCommand(redisClient *c) { void multiCommand(client *c) {
if (c->flags & REDIS_MULTI) { if (c->flags & REDIS_MULTI) {
addReplyError(c,"MULTI calls can not be nested"); addReplyError(c,"MULTI calls can not be nested");
return; return;
...@@ -92,7 +92,7 @@ void multiCommand(redisClient *c) { ...@@ -92,7 +92,7 @@ void multiCommand(redisClient *c) {
addReply(c,shared.ok); addReply(c,shared.ok);
} }
void discardCommand(redisClient *c) { void discardCommand(client *c) {
if (!(c->flags & REDIS_MULTI)) { if (!(c->flags & REDIS_MULTI)) {
addReplyError(c,"DISCARD without MULTI"); addReplyError(c,"DISCARD without MULTI");
return; return;
...@@ -103,7 +103,7 @@ void discardCommand(redisClient *c) { ...@@ -103,7 +103,7 @@ void discardCommand(redisClient *c) {
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand /* Send a MULTI command to all the slaves and AOF file. Check the execCommand
* implementation for more information. */ * implementation for more information. */
void execCommandPropagateMulti(redisClient *c) { void execCommandPropagateMulti(client *c) {
robj *multistring = createStringObject("MULTI",5); robj *multistring = createStringObject("MULTI",5);
propagate(server.multiCommand,c->db->id,&multistring,1, propagate(server.multiCommand,c->db->id,&multistring,1,
...@@ -111,7 +111,7 @@ void execCommandPropagateMulti(redisClient *c) { ...@@ -111,7 +111,7 @@ void execCommandPropagateMulti(redisClient *c) {
decrRefCount(multistring); decrRefCount(multistring);
} }
void execCommand(redisClient *c) { void execCommand(client *c) {
int j; int j;
robj **orig_argv; robj **orig_argv;
int orig_argc; int orig_argc;
...@@ -199,7 +199,7 @@ typedef struct watchedKey { ...@@ -199,7 +199,7 @@ typedef struct watchedKey {
} watchedKey; } watchedKey;
/* Watch for the specified key */ /* Watch for the specified key */
void watchForKey(redisClient *c, robj *key) { void watchForKey(client *c, robj *key) {
list *clients = NULL; list *clients = NULL;
listIter li; listIter li;
listNode *ln; listNode *ln;
...@@ -230,7 +230,7 @@ void watchForKey(redisClient *c, robj *key) { ...@@ -230,7 +230,7 @@ void watchForKey(redisClient *c, robj *key) {
/* Unwatch all the keys watched by this client. To clean the EXEC dirty /* Unwatch all the keys watched by this client. To clean the EXEC dirty
* flag is up to the caller. */ * flag is up to the caller. */
void unwatchAllKeys(redisClient *c) { void unwatchAllKeys(client *c) {
listIter li; listIter li;
listNode *ln; listNode *ln;
...@@ -271,7 +271,7 @@ void touchWatchedKey(redisDb *db, robj *key) { ...@@ -271,7 +271,7 @@ void touchWatchedKey(redisDb *db, robj *key) {
/* Check if we are already watching for this key */ /* Check if we are already watching for this key */
listRewind(clients,&li); listRewind(clients,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *c = listNodeValue(ln); client *c = listNodeValue(ln);
c->flags |= REDIS_DIRTY_CAS; c->flags |= REDIS_DIRTY_CAS;
} }
...@@ -288,7 +288,7 @@ void touchWatchedKeysOnFlush(int dbid) { ...@@ -288,7 +288,7 @@ void touchWatchedKeysOnFlush(int dbid) {
/* For every client, check all the waited keys */ /* For every client, check all the waited keys */
listRewind(server.clients,&li1); listRewind(server.clients,&li1);
while((ln = listNext(&li1))) { while((ln = listNext(&li1))) {
redisClient *c = listNodeValue(ln); client *c = listNodeValue(ln);
listRewind(c->watched_keys,&li2); listRewind(c->watched_keys,&li2);
while((ln = listNext(&li2))) { while((ln = listNext(&li2))) {
watchedKey *wk = listNodeValue(ln); watchedKey *wk = listNodeValue(ln);
...@@ -304,7 +304,7 @@ void touchWatchedKeysOnFlush(int dbid) { ...@@ -304,7 +304,7 @@ void touchWatchedKeysOnFlush(int dbid) {
} }
} }
void watchCommand(redisClient *c) { void watchCommand(client *c) {
int j; int j;
if (c->flags & REDIS_MULTI) { if (c->flags & REDIS_MULTI) {
...@@ -316,7 +316,7 @@ void watchCommand(redisClient *c) { ...@@ -316,7 +316,7 @@ void watchCommand(redisClient *c) {
addReply(c,shared.ok); addReply(c,shared.ok);
} }
void unwatchCommand(redisClient *c) { void unwatchCommand(client *c) {
unwatchAllKeys(c); unwatchAllKeys(c);
c->flags &= (~REDIS_DIRTY_CAS); c->flags &= (~REDIS_DIRTY_CAS);
addReply(c,shared.ok); addReply(c,shared.ok);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <sys/uio.h> #include <sys/uio.h>
#include <math.h> #include <math.h>
static void setProtocolError(redisClient *c, int pos); static void setProtocolError(client *c, int pos);
/* Return the size consumed from the allocator, for the specified SDS string, /* Return the size consumed from the allocator, for the specified SDS string,
* including internal fragmentation. This function is used in order to compute * including internal fragmentation. This function is used in order to compute
...@@ -61,8 +61,8 @@ int listMatchObjects(void *a, void *b) { ...@@ -61,8 +61,8 @@ int listMatchObjects(void *a, void *b) {
return equalStringObjects(a,b); return equalStringObjects(a,b);
} }
redisClient *createClient(int fd) { client *createClient(int fd) {
redisClient *c = zmalloc(sizeof(redisClient)); client *c = zmalloc(sizeof(client));
/* passing -1 as fd it is possible to create a non connected client. /* passing -1 as fd it is possible to create a non connected client.
* This is useful since all the Redis commands needs to be executed * This is useful since all the Redis commands needs to be executed
...@@ -150,7 +150,7 @@ redisClient *createClient(int fd) { ...@@ -150,7 +150,7 @@ redisClient *createClient(int fd) {
* Typically gets called every time a reply is built, before adding more * Typically gets called every time a reply is built, before adding more
* data to the clients output buffers. If the function returns REDIS_ERR no * data to the clients output buffers. If the function returns REDIS_ERR no
* data should be appended to the output buffers. */ * data should be appended to the output buffers. */
int prepareClientToWrite(redisClient *c) { int prepareClientToWrite(client *c) {
/* If it's the Lua client we always return ok without installing any /* If it's the Lua client we always return ok without installing any
* handler since there is no socket at all. */ * handler since there is no socket at all. */
if (c->flags & REDIS_LUA_CLIENT) return REDIS_OK; if (c->flags & REDIS_LUA_CLIENT) return REDIS_OK;
...@@ -201,7 +201,7 @@ robj *dupLastObjectIfNeeded(list *reply) { ...@@ -201,7 +201,7 @@ robj *dupLastObjectIfNeeded(list *reply) {
* Low level functions to add more data to output buffers. * Low level functions to add more data to output buffers.
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
int _addReplyToBuffer(redisClient *c, const char *s, size_t len) { int _addReplyToBuffer(client *c, const char *s, size_t len) {
size_t available = sizeof(c->buf)-c->bufpos; size_t available = sizeof(c->buf)-c->bufpos;
if (c->flags & REDIS_CLOSE_AFTER_REPLY) return REDIS_OK; if (c->flags & REDIS_CLOSE_AFTER_REPLY) return REDIS_OK;
...@@ -218,7 +218,7 @@ int _addReplyToBuffer(redisClient *c, const char *s, size_t len) { ...@@ -218,7 +218,7 @@ int _addReplyToBuffer(redisClient *c, const char *s, size_t len) {
return REDIS_OK; return REDIS_OK;
} }
void _addReplyObjectToList(redisClient *c, robj *o) { void _addReplyObjectToList(client *c, robj *o) {
robj *tail; robj *tail;
if (c->flags & REDIS_CLOSE_AFTER_REPLY) return; if (c->flags & REDIS_CLOSE_AFTER_REPLY) return;
...@@ -250,7 +250,7 @@ void _addReplyObjectToList(redisClient *c, robj *o) { ...@@ -250,7 +250,7 @@ void _addReplyObjectToList(redisClient *c, robj *o) {
/* This method takes responsibility over the sds. When it is no longer /* This method takes responsibility over the sds. When it is no longer
* needed it will be free'd, otherwise it ends up in a robj. */ * needed it will be free'd, otherwise it ends up in a robj. */
void _addReplySdsToList(redisClient *c, sds s) { void _addReplySdsToList(client *c, sds s) {
robj *tail; robj *tail;
if (c->flags & REDIS_CLOSE_AFTER_REPLY) { if (c->flags & REDIS_CLOSE_AFTER_REPLY) {
...@@ -281,7 +281,7 @@ void _addReplySdsToList(redisClient *c, sds s) { ...@@ -281,7 +281,7 @@ void _addReplySdsToList(redisClient *c, sds s) {
asyncCloseClientOnOutputBufferLimitReached(c); asyncCloseClientOnOutputBufferLimitReached(c);
} }
void _addReplyStringToList(redisClient *c, const char *s, size_t len) { void _addReplyStringToList(client *c, const char *s, size_t len) {
robj *tail; robj *tail;
if (c->flags & REDIS_CLOSE_AFTER_REPLY) return; if (c->flags & REDIS_CLOSE_AFTER_REPLY) return;
...@@ -317,7 +317,7 @@ void _addReplyStringToList(redisClient *c, const char *s, size_t len) { ...@@ -317,7 +317,7 @@ void _addReplyStringToList(redisClient *c, const char *s, size_t len) {
* The following functions are the ones that commands implementations will call. * The following functions are the ones that commands implementations will call.
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
void addReply(redisClient *c, robj *obj) { void addReply(client *c, robj *obj) {
if (prepareClientToWrite(c) != REDIS_OK) return; if (prepareClientToWrite(c) != REDIS_OK) return;
/* This is an important place where we can avoid copy-on-write /* This is an important place where we can avoid copy-on-write
...@@ -353,7 +353,7 @@ void addReply(redisClient *c, robj *obj) { ...@@ -353,7 +353,7 @@ void addReply(redisClient *c, robj *obj) {
} }
} }
void addReplySds(redisClient *c, sds s) { void addReplySds(client *c, sds s) {
if (prepareClientToWrite(c) != REDIS_OK) { if (prepareClientToWrite(c) != REDIS_OK) {
/* The caller expects the sds to be free'd. */ /* The caller expects the sds to be free'd. */
sdsfree(s); sdsfree(s);
...@@ -367,23 +367,23 @@ void addReplySds(redisClient *c, sds s) { ...@@ -367,23 +367,23 @@ void addReplySds(redisClient *c, sds s) {
} }
} }
void addReplyString(redisClient *c, const char *s, size_t len) { void addReplyString(client *c, const char *s, size_t len) {
if (prepareClientToWrite(c) != REDIS_OK) return; if (prepareClientToWrite(c) != REDIS_OK) return;
if (_addReplyToBuffer(c,s,len) != REDIS_OK) if (_addReplyToBuffer(c,s,len) != REDIS_OK)
_addReplyStringToList(c,s,len); _addReplyStringToList(c,s,len);
} }
void addReplyErrorLength(redisClient *c, const char *s, size_t len) { void addReplyErrorLength(client *c, const char *s, size_t len) {
addReplyString(c,"-ERR ",5); addReplyString(c,"-ERR ",5);
addReplyString(c,s,len); addReplyString(c,s,len);
addReplyString(c,"\r\n",2); addReplyString(c,"\r\n",2);
} }
void addReplyError(redisClient *c, const char *err) { void addReplyError(client *c, const char *err) {
addReplyErrorLength(c,err,strlen(err)); addReplyErrorLength(c,err,strlen(err));
} }
void addReplyErrorFormat(redisClient *c, const char *fmt, ...) { void addReplyErrorFormat(client *c, const char *fmt, ...) {
size_t l, j; size_t l, j;
va_list ap; va_list ap;
va_start(ap,fmt); va_start(ap,fmt);
...@@ -399,17 +399,17 @@ void addReplyErrorFormat(redisClient *c, const char *fmt, ...) { ...@@ -399,17 +399,17 @@ void addReplyErrorFormat(redisClient *c, const char *fmt, ...) {
sdsfree(s); sdsfree(s);
} }
void addReplyStatusLength(redisClient *c, const char *s, size_t len) { void addReplyStatusLength(client *c, const char *s, size_t len) {
addReplyString(c,"+",1); addReplyString(c,"+",1);
addReplyString(c,s,len); addReplyString(c,s,len);
addReplyString(c,"\r\n",2); addReplyString(c,"\r\n",2);
} }
void addReplyStatus(redisClient *c, const char *status) { void addReplyStatus(client *c, const char *status) {
addReplyStatusLength(c,status,strlen(status)); addReplyStatusLength(c,status,strlen(status));
} }
void addReplyStatusFormat(redisClient *c, const char *fmt, ...) { void addReplyStatusFormat(client *c, const char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap,fmt); va_start(ap,fmt);
sds s = sdscatvprintf(sdsempty(),fmt,ap); sds s = sdscatvprintf(sdsempty(),fmt,ap);
...@@ -420,7 +420,7 @@ void addReplyStatusFormat(redisClient *c, const char *fmt, ...) { ...@@ -420,7 +420,7 @@ void addReplyStatusFormat(redisClient *c, const char *fmt, ...) {
/* Adds an empty object to the reply list that will contain the multi bulk /* Adds an empty object to the reply list that will contain the multi bulk
* length, which is not known when this function is called. */ * length, which is not known when this function is called. */
void *addDeferredMultiBulkLength(redisClient *c) { void *addDeferredMultiBulkLength(client *c) {
/* Note that we install the write event here even if the object is not /* Note that we install the write event here even if the object is not
* ready to be sent, since we are sure that before returning to the * ready to be sent, since we are sure that before returning to the
* event loop setDeferredMultiBulkLength() will be called. */ * event loop setDeferredMultiBulkLength() will be called. */
...@@ -430,7 +430,7 @@ void *addDeferredMultiBulkLength(redisClient *c) { ...@@ -430,7 +430,7 @@ void *addDeferredMultiBulkLength(redisClient *c) {
} }
/* Populate the length object and try gluing it to the next chunk. */ /* Populate the length object and try gluing it to the next chunk. */
void setDeferredMultiBulkLength(redisClient *c, void *node, long length) { void setDeferredMultiBulkLength(client *c, void *node, long length) {
listNode *ln = (listNode*)node; listNode *ln = (listNode*)node;
robj *len, *next; robj *len, *next;
...@@ -457,7 +457,7 @@ void setDeferredMultiBulkLength(redisClient *c, void *node, long length) { ...@@ -457,7 +457,7 @@ void setDeferredMultiBulkLength(redisClient *c, void *node, long length) {
} }
/* Add a double as a bulk reply */ /* Add a double as a bulk reply */
void addReplyDouble(redisClient *c, double d) { void addReplyDouble(client *c, double d) {
char dbuf[128], sbuf[128]; char dbuf[128], sbuf[128];
int dlen, slen; int dlen, slen;
if (isinf(d)) { if (isinf(d)) {
...@@ -473,7 +473,7 @@ void addReplyDouble(redisClient *c, double d) { ...@@ -473,7 +473,7 @@ void addReplyDouble(redisClient *c, double d) {
/* Add a long long as integer reply or bulk len / multi bulk count. /* Add a long long as integer reply or bulk len / multi bulk count.
* Basically this is used to output <prefix><long long><crlf>. */ * Basically this is used to output <prefix><long long><crlf>. */
void addReplyLongLongWithPrefix(redisClient *c, long long ll, char prefix) { void addReplyLongLongWithPrefix(client *c, long long ll, char prefix) {
char buf[128]; char buf[128];
int len; int len;
...@@ -495,7 +495,7 @@ void addReplyLongLongWithPrefix(redisClient *c, long long ll, char prefix) { ...@@ -495,7 +495,7 @@ void addReplyLongLongWithPrefix(redisClient *c, long long ll, char prefix) {
addReplyString(c,buf,len+3); addReplyString(c,buf,len+3);
} }
void addReplyLongLong(redisClient *c, long long ll) { void addReplyLongLong(client *c, long long ll) {
if (ll == 0) if (ll == 0)
addReply(c,shared.czero); addReply(c,shared.czero);
else if (ll == 1) else if (ll == 1)
...@@ -504,7 +504,7 @@ void addReplyLongLong(redisClient *c, long long ll) { ...@@ -504,7 +504,7 @@ void addReplyLongLong(redisClient *c, long long ll) {
addReplyLongLongWithPrefix(c,ll,':'); addReplyLongLongWithPrefix(c,ll,':');
} }
void addReplyMultiBulkLen(redisClient *c, long length) { void addReplyMultiBulkLen(client *c, long length) {
if (length < REDIS_SHARED_BULKHDR_LEN) if (length < REDIS_SHARED_BULKHDR_LEN)
addReply(c,shared.mbulkhdr[length]); addReply(c,shared.mbulkhdr[length]);
else else
...@@ -512,7 +512,7 @@ void addReplyMultiBulkLen(redisClient *c, long length) { ...@@ -512,7 +512,7 @@ void addReplyMultiBulkLen(redisClient *c, long length) {
} }
/* Create the length prefix of a bulk reply, example: $2234 */ /* Create the length prefix of a bulk reply, example: $2234 */
void addReplyBulkLen(redisClient *c, robj *obj) { void addReplyBulkLen(client *c, robj *obj) {
size_t len; size_t len;
if (sdsEncodedObject(obj)) { if (sdsEncodedObject(obj)) {
...@@ -538,21 +538,21 @@ void addReplyBulkLen(redisClient *c, robj *obj) { ...@@ -538,21 +538,21 @@ void addReplyBulkLen(redisClient *c, robj *obj) {
} }
/* Add a Redis Object as a bulk reply */ /* Add a Redis Object as a bulk reply */
void addReplyBulk(redisClient *c, robj *obj) { void addReplyBulk(client *c, robj *obj) {
addReplyBulkLen(c,obj); addReplyBulkLen(c,obj);
addReply(c,obj); addReply(c,obj);
addReply(c,shared.crlf); addReply(c,shared.crlf);
} }
/* Add a C buffer as bulk reply */ /* Add a C buffer as bulk reply */
void addReplyBulkCBuffer(redisClient *c, const void *p, size_t len) { void addReplyBulkCBuffer(client *c, const void *p, size_t len) {
addReplyLongLongWithPrefix(c,len,'$'); addReplyLongLongWithPrefix(c,len,'$');
addReplyString(c,p,len); addReplyString(c,p,len);
addReply(c,shared.crlf); addReply(c,shared.crlf);
} }
/* Add sds to reply (takes ownership of sds and frees it) */ /* Add sds to reply (takes ownership of sds and frees it) */
void addReplyBulkSds(redisClient *c, sds s) { void addReplyBulkSds(client *c, sds s) {
addReplySds(c,sdscatfmt(sdsempty(),"$%u\r\n", addReplySds(c,sdscatfmt(sdsempty(),"$%u\r\n",
(unsigned long)sdslen(s))); (unsigned long)sdslen(s)));
addReplySds(c,s); addReplySds(c,s);
...@@ -560,7 +560,7 @@ void addReplyBulkSds(redisClient *c, sds s) { ...@@ -560,7 +560,7 @@ void addReplyBulkSds(redisClient *c, sds s) {
} }
/* Add a C nul term string as bulk reply */ /* Add a C nul term string as bulk reply */
void addReplyBulkCString(redisClient *c, const char *s) { void addReplyBulkCString(client *c, const char *s) {
if (s == NULL) { if (s == NULL) {
addReply(c,shared.nullbulk); addReply(c,shared.nullbulk);
} else { } else {
...@@ -569,7 +569,7 @@ void addReplyBulkCString(redisClient *c, const char *s) { ...@@ -569,7 +569,7 @@ void addReplyBulkCString(redisClient *c, const char *s) {
} }
/* Add a long long as a bulk reply */ /* Add a long long as a bulk reply */
void addReplyBulkLongLong(redisClient *c, long long ll) { void addReplyBulkLongLong(client *c, long long ll) {
char buf[64]; char buf[64];
int len; int len;
...@@ -580,7 +580,7 @@ void addReplyBulkLongLong(redisClient *c, long long ll) { ...@@ -580,7 +580,7 @@ void addReplyBulkLongLong(redisClient *c, long long ll) {
/* Copy 'src' client output buffers into 'dst' client output buffers. /* Copy 'src' client output buffers into 'dst' client output buffers.
* The function takes care of freeing the old output buffers of the * The function takes care of freeing the old output buffers of the
* destination client. */ * destination client. */
void copyClientOutputBuffer(redisClient *dst, redisClient *src) { void copyClientOutputBuffer(client *dst, client *src) {
listRelease(dst->reply); listRelease(dst->reply);
dst->reply = listDup(src->reply); dst->reply = listDup(src->reply);
memcpy(dst->buf,src->buf,src->bufpos); memcpy(dst->buf,src->buf,src->bufpos);
...@@ -590,7 +590,7 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) { ...@@ -590,7 +590,7 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) {
#define MAX_ACCEPTS_PER_CALL 1000 #define MAX_ACCEPTS_PER_CALL 1000
static void acceptCommonHandler(int fd, int flags) { static void acceptCommonHandler(int fd, int flags) {
redisClient *c; client *c;
if ((c = createClient(fd)) == NULL) { if ((c = createClient(fd)) == NULL) {
serverLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Error registering fd event for the new client: %s (fd=%d)", "Error registering fd event for the new client: %s (fd=%d)",
...@@ -656,7 +656,7 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -656,7 +656,7 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
} }
} }
static void freeClientArgv(redisClient *c) { static void freeClientArgv(client *c) {
int j; int j;
for (j = 0; j < c->argc; j++) for (j = 0; j < c->argc; j++)
decrRefCount(c->argv[j]); decrRefCount(c->argv[j]);
...@@ -670,7 +670,7 @@ static void freeClientArgv(redisClient *c) { ...@@ -670,7 +670,7 @@ static void freeClientArgv(redisClient *c) {
void disconnectSlaves(void) { void disconnectSlaves(void) {
while (listLength(server.slaves)) { while (listLength(server.slaves)) {
listNode *ln = listFirst(server.slaves); listNode *ln = listFirst(server.slaves);
freeClient((redisClient*)ln->value); freeClient((client*)ln->value);
} }
} }
...@@ -688,7 +688,7 @@ void replicationHandleMasterDisconnection(void) { ...@@ -688,7 +688,7 @@ void replicationHandleMasterDisconnection(void) {
if (server.masterhost != NULL) disconnectSlaves(); if (server.masterhost != NULL) disconnectSlaves();
} }
void freeClient(redisClient *c) { void freeClient(client *c) {
listNode *ln; listNode *ln;
/* If this is marked as current client unset it */ /* If this is marked as current client unset it */
...@@ -804,7 +804,7 @@ void freeClient(redisClient *c) { ...@@ -804,7 +804,7 @@ void freeClient(redisClient *c) {
* This function is useful when we need to terminate a client but we are in * This function is useful when we need to terminate a client but we are in
* a context where calling freeClient() is not possible, because the client * a context where calling freeClient() is not possible, because the client
* should be valid for the continuation of the flow of the program. */ * should be valid for the continuation of the flow of the program. */
void freeClientAsync(redisClient *c) { void freeClientAsync(client *c) {
if (c->flags & REDIS_CLOSE_ASAP || c->flags & REDIS_LUA_CLIENT) return; if (c->flags & REDIS_CLOSE_ASAP || c->flags & REDIS_LUA_CLIENT) return;
c->flags |= REDIS_CLOSE_ASAP; c->flags |= REDIS_CLOSE_ASAP;
listAddNodeTail(server.clients_to_close,c); listAddNodeTail(server.clients_to_close,c);
...@@ -813,7 +813,7 @@ void freeClientAsync(redisClient *c) { ...@@ -813,7 +813,7 @@ void freeClientAsync(redisClient *c) {
void freeClientsInAsyncFreeQueue(void) { void freeClientsInAsyncFreeQueue(void) {
while (listLength(server.clients_to_close)) { while (listLength(server.clients_to_close)) {
listNode *ln = listFirst(server.clients_to_close); listNode *ln = listFirst(server.clients_to_close);
redisClient *c = listNodeValue(ln); client *c = listNodeValue(ln);
c->flags &= ~REDIS_CLOSE_ASAP; c->flags &= ~REDIS_CLOSE_ASAP;
freeClient(c); freeClient(c);
...@@ -822,7 +822,7 @@ void freeClientsInAsyncFreeQueue(void) { ...@@ -822,7 +822,7 @@ void freeClientsInAsyncFreeQueue(void) {
} }
void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) { void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
redisClient *c = privdata; client *c = privdata;
ssize_t nwritten = 0, totwritten = 0; ssize_t nwritten = 0, totwritten = 0;
size_t objlen; size_t objlen;
size_t objmem; size_t objmem;
...@@ -906,7 +906,7 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -906,7 +906,7 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
} }
/* resetClient prepare the client to process the next command */ /* resetClient prepare the client to process the next command */
void resetClient(redisClient *c) { void resetClient(client *c) {
redisCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL; redisCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL;
freeClientArgv(c); freeClientArgv(c);
...@@ -919,7 +919,7 @@ void resetClient(redisClient *c) { ...@@ -919,7 +919,7 @@ void resetClient(redisClient *c) {
c->flags &= (~REDIS_ASKING); c->flags &= (~REDIS_ASKING);
} }
int processInlineBuffer(redisClient *c) { int processInlineBuffer(client *c) {
char *newline; char *newline;
int argc, j; int argc, j;
sds *argv, aux; sds *argv, aux;
...@@ -982,7 +982,7 @@ int processInlineBuffer(redisClient *c) { ...@@ -982,7 +982,7 @@ int processInlineBuffer(redisClient *c) {
/* Helper function. Trims query buffer to make the function that processes /* Helper function. Trims query buffer to make the function that processes
* multi bulk requests idempotent. */ * multi bulk requests idempotent. */
static void setProtocolError(redisClient *c, int pos) { static void setProtocolError(client *c, int pos) {
if (server.verbosity <= REDIS_VERBOSE) { if (server.verbosity <= REDIS_VERBOSE) {
sds client = catClientInfoString(sdsempty(),c); sds client = catClientInfoString(sdsempty(),c);
serverLog(REDIS_VERBOSE, serverLog(REDIS_VERBOSE,
...@@ -993,7 +993,7 @@ static void setProtocolError(redisClient *c, int pos) { ...@@ -993,7 +993,7 @@ static void setProtocolError(redisClient *c, int pos) {
sdsrange(c->querybuf,pos,-1); sdsrange(c->querybuf,pos,-1);
} }
int processMultibulkBuffer(redisClient *c) { int processMultibulkBuffer(client *c) {
char *newline = NULL; char *newline = NULL;
int pos = 0, ok; int pos = 0, ok;
long long ll; long long ll;
...@@ -1131,7 +1131,7 @@ int processMultibulkBuffer(redisClient *c) { ...@@ -1131,7 +1131,7 @@ int processMultibulkBuffer(redisClient *c) {
return REDIS_ERR; return REDIS_ERR;
} }
void processInputBuffer(redisClient *c) { void processInputBuffer(client *c) {
server.current_client = c; server.current_client = c;
/* Keep processing while there is something in the input buffer */ /* Keep processing while there is something in the input buffer */
while(sdslen(c->querybuf)) { while(sdslen(c->querybuf)) {
...@@ -1176,7 +1176,7 @@ void processInputBuffer(redisClient *c) { ...@@ -1176,7 +1176,7 @@ void processInputBuffer(redisClient *c) {
} }
void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
redisClient *c = (redisClient*) privdata; client *c = (client*) privdata;
int nread, readlen; int nread, readlen;
size_t qblen; size_t qblen;
REDIS_NOTUSED(el); REDIS_NOTUSED(el);
...@@ -1234,7 +1234,7 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -1234,7 +1234,7 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
void getClientsMaxBuffers(unsigned long *longest_output_list, void getClientsMaxBuffers(unsigned long *longest_output_list,
unsigned long *biggest_input_buffer) { unsigned long *biggest_input_buffer) {
redisClient *c; client *c;
listNode *ln; listNode *ln;
listIter li; listIter li;
unsigned long lol = 0, bib = 0; unsigned long lol = 0, bib = 0;
...@@ -1261,7 +1261,7 @@ void getClientsMaxBuffers(unsigned long *longest_output_list, ...@@ -1261,7 +1261,7 @@ void getClientsMaxBuffers(unsigned long *longest_output_list,
* On failure the function still populates 'peerid' with the "?:0" string * On failure the function still populates 'peerid' with the "?:0" string
* in case you want to relax error checking or need to display something * in case you want to relax error checking or need to display something
* anyway (see anetPeerToString implementation for more info). */ * anyway (see anetPeerToString implementation for more info). */
void genClientPeerId(redisClient *client, char *peerid, void genClientPeerId(client *client, char *peerid,
size_t peerid_len) { size_t peerid_len) {
if (client->flags & REDIS_UNIX_SOCKET) { if (client->flags & REDIS_UNIX_SOCKET) {
/* Unix socket client. */ /* Unix socket client. */
...@@ -1276,7 +1276,7 @@ void genClientPeerId(redisClient *client, char *peerid, ...@@ -1276,7 +1276,7 @@ void genClientPeerId(redisClient *client, char *peerid,
* if client->peerid is NULL, otherwise returning the cached value. * if client->peerid is NULL, otherwise returning the cached value.
* The Peer ID never changes during the life of the client, however it * The Peer ID never changes during the life of the client, however it
* is expensive to compute. */ * is expensive to compute. */
char *getClientPeerId(redisClient *c) { char *getClientPeerId(client *c) {
char peerid[REDIS_PEER_ID_LEN]; char peerid[REDIS_PEER_ID_LEN];
if (c->peerid == NULL) { if (c->peerid == NULL) {
...@@ -1288,7 +1288,7 @@ char *getClientPeerId(redisClient *c) { ...@@ -1288,7 +1288,7 @@ char *getClientPeerId(redisClient *c) {
/* Concatenate a string representing the state of a client in an human /* Concatenate a string representing the state of a client in an human
* readable format, into the sds string 's'. */ * readable format, into the sds string 's'. */
sds catClientInfoString(sds s, redisClient *client) { sds catClientInfoString(sds s, client *client) {
char flags[16], events[3], *p; char flags[16], events[3], *p;
int emask; int emask;
...@@ -1341,7 +1341,7 @@ sds catClientInfoString(sds s, redisClient *client) { ...@@ -1341,7 +1341,7 @@ sds catClientInfoString(sds s, redisClient *client) {
sds getAllClientsInfoString(void) { sds getAllClientsInfoString(void) {
listNode *ln; listNode *ln;
listIter li; listIter li;
redisClient *client; client *client;
sds o = sdsempty(); sds o = sdsempty();
o = sdsMakeRoomFor(o,200*listLength(server.clients)); o = sdsMakeRoomFor(o,200*listLength(server.clients));
...@@ -1354,10 +1354,10 @@ sds getAllClientsInfoString(void) { ...@@ -1354,10 +1354,10 @@ sds getAllClientsInfoString(void) {
return o; return o;
} }
void clientCommand(redisClient *c) { void clientCommand(client *c) {
listNode *ln; listNode *ln;
listIter li; listIter li;
redisClient *client; client *client;
if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) { if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
/* CLIENT LIST */ /* CLIENT LIST */
...@@ -1500,7 +1500,7 @@ void clientCommand(redisClient *c) { ...@@ -1500,7 +1500,7 @@ void clientCommand(redisClient *c) {
/* Rewrite the command vector of the client. All the new objects ref count /* Rewrite the command vector of the client. All the new objects ref count
* is incremented. The old command vector is freed, and the old objects * is incremented. The old command vector is freed, and the old objects
* ref count is decremented. */ * ref count is decremented. */
void rewriteClientCommandVector(redisClient *c, int argc, ...) { void rewriteClientCommandVector(client *c, int argc, ...) {
va_list ap; va_list ap;
int j; int j;
robj **argv; /* The new argument vector */ robj **argv; /* The new argument vector */
...@@ -1528,7 +1528,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) { ...@@ -1528,7 +1528,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
} }
/* Completely replace the client command vector with the provided one. */ /* Completely replace the client command vector with the provided one. */
void replaceClientCommandVector(redisClient *c, int argc, robj **argv) { void replaceClientCommandVector(client *c, int argc, robj **argv) {
freeClientArgv(c); freeClientArgv(c);
zfree(c->argv); zfree(c->argv);
c->argv = argv; c->argv = argv;
...@@ -1539,7 +1539,7 @@ void replaceClientCommandVector(redisClient *c, int argc, robj **argv) { ...@@ -1539,7 +1539,7 @@ void replaceClientCommandVector(redisClient *c, int argc, robj **argv) {
/* Rewrite a single item in the command vector. /* Rewrite a single item in the command vector.
* The new val ref count is incremented, and the old decremented. */ * The new val ref count is incremented, and the old decremented. */
void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) { void rewriteClientCommandArgument(client *c, int i, robj *newval) {
robj *oldval; robj *oldval;
redisAssertWithInfo(c,NULL,i < c->argc); redisAssertWithInfo(c,NULL,i < c->argc);
...@@ -1568,7 +1568,7 @@ void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) { ...@@ -1568,7 +1568,7 @@ void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) {
* Note: this function is very fast so can be called as many time as * Note: this function is very fast so can be called as many time as
* the caller wishes. The main usage of this function currently is * the caller wishes. The main usage of this function currently is
* enforcing the client output length limits. */ * enforcing the client output length limits. */
unsigned long getClientOutputBufferMemoryUsage(redisClient *c) { unsigned long getClientOutputBufferMemoryUsage(client *c) {
unsigned long list_item_size = sizeof(listNode)+sizeof(robj); unsigned long list_item_size = sizeof(listNode)+sizeof(robj);
return c->reply_bytes + (list_item_size*listLength(c->reply)); return c->reply_bytes + (list_item_size*listLength(c->reply));
...@@ -1582,7 +1582,7 @@ unsigned long getClientOutputBufferMemoryUsage(redisClient *c) { ...@@ -1582,7 +1582,7 @@ unsigned long getClientOutputBufferMemoryUsage(redisClient *c) {
* REDIS_CLIENT_TYPE_SLAVE -> Slave or client executing MONITOR command * REDIS_CLIENT_TYPE_SLAVE -> Slave or client executing MONITOR command
* REDIS_CLIENT_TYPE_PUBSUB -> Client subscribed to Pub/Sub channels * REDIS_CLIENT_TYPE_PUBSUB -> Client subscribed to Pub/Sub channels
*/ */
int getClientType(redisClient *c) { int getClientType(client *c) {
if ((c->flags & REDIS_SLAVE) && !(c->flags & REDIS_MONITOR)) if ((c->flags & REDIS_SLAVE) && !(c->flags & REDIS_MONITOR))
return REDIS_CLIENT_TYPE_SLAVE; return REDIS_CLIENT_TYPE_SLAVE;
if (c->flags & REDIS_PUBSUB) if (c->flags & REDIS_PUBSUB)
...@@ -1612,7 +1612,7 @@ char *getClientTypeName(int class) { ...@@ -1612,7 +1612,7 @@ char *getClientTypeName(int class) {
* *
* Return value: non-zero if the client reached the soft or the hard limit. * Return value: non-zero if the client reached the soft or the hard limit.
* Otherwise zero is returned. */ * Otherwise zero is returned. */
int checkClientOutputBufferLimits(redisClient *c) { int checkClientOutputBufferLimits(client *c) {
int soft = 0, hard = 0, class; int soft = 0, hard = 0, class;
unsigned long used_mem = getClientOutputBufferMemoryUsage(c); unsigned long used_mem = getClientOutputBufferMemoryUsage(c);
...@@ -1653,7 +1653,7 @@ int checkClientOutputBufferLimits(redisClient *c) { ...@@ -1653,7 +1653,7 @@ int checkClientOutputBufferLimits(redisClient *c) {
* Note: we need to close the client asynchronously because this function is * Note: we need to close the client asynchronously because this function is
* called from contexts where the client can't be freed safely, i.e. from the * called from contexts where the client can't be freed safely, i.e. from the
* lower level functions pushing data inside the client output buffers. */ * lower level functions pushing data inside the client output buffers. */
void asyncCloseClientOnOutputBufferLimitReached(redisClient *c) { void asyncCloseClientOnOutputBufferLimitReached(client *c) {
redisAssert(c->reply_bytes < SIZE_MAX-(1024*64)); redisAssert(c->reply_bytes < SIZE_MAX-(1024*64));
if (c->reply_bytes == 0 || c->flags & REDIS_CLOSE_ASAP) return; if (c->reply_bytes == 0 || c->flags & REDIS_CLOSE_ASAP) return;
if (checkClientOutputBufferLimits(c)) { if (checkClientOutputBufferLimits(c)) {
...@@ -1673,7 +1673,7 @@ void flushSlavesOutputBuffers(void) { ...@@ -1673,7 +1673,7 @@ void flushSlavesOutputBuffers(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = listNodeValue(ln); client *slave = listNodeValue(ln);
int events; int events;
events = aeGetFileEvents(server.el,slave->fd); events = aeGetFileEvents(server.el,slave->fd);
...@@ -1717,7 +1717,7 @@ int clientsArePaused(void) { ...@@ -1717,7 +1717,7 @@ int clientsArePaused(void) {
{ {
listNode *ln; listNode *ln;
listIter li; listIter li;
redisClient *c; client *c;
server.clients_paused = 0; server.clients_paused = 0;
......
...@@ -339,7 +339,7 @@ robj *resetRefCount(robj *obj) { ...@@ -339,7 +339,7 @@ robj *resetRefCount(robj *obj) {
return obj; return obj;
} }
int checkType(redisClient *c, robj *o, int type) { int checkType(client *c, robj *o, int type) {
if (o->type != type) { if (o->type != type) {
addReply(c,shared.wrongtypeerr); addReply(c,shared.wrongtypeerr);
return 1; return 1;
...@@ -562,7 +562,7 @@ int getDoubleFromObject(robj *o, double *target) { ...@@ -562,7 +562,7 @@ int getDoubleFromObject(robj *o, double *target) {
return REDIS_OK; return REDIS_OK;
} }
int getDoubleFromObjectOrReply(redisClient *c, robj *o, double *target, const char *msg) { int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const char *msg) {
double value; double value;
if (getDoubleFromObject(o, &value) != REDIS_OK) { if (getDoubleFromObject(o, &value) != REDIS_OK) {
if (msg != NULL) { if (msg != NULL) {
...@@ -600,7 +600,7 @@ int getLongDoubleFromObject(robj *o, long double *target) { ...@@ -600,7 +600,7 @@ int getLongDoubleFromObject(robj *o, long double *target) {
return REDIS_OK; return REDIS_OK;
} }
int getLongDoubleFromObjectOrReply(redisClient *c, robj *o, long double *target, const char *msg) { int getLongDoubleFromObjectOrReply(client *c, robj *o, long double *target, const char *msg) {
long double value; long double value;
if (getLongDoubleFromObject(o, &value) != REDIS_OK) { if (getLongDoubleFromObject(o, &value) != REDIS_OK) {
if (msg != NULL) { if (msg != NULL) {
...@@ -638,7 +638,7 @@ int getLongLongFromObject(robj *o, long long *target) { ...@@ -638,7 +638,7 @@ int getLongLongFromObject(robj *o, long long *target) {
return REDIS_OK; return REDIS_OK;
} }
int getLongLongFromObjectOrReply(redisClient *c, robj *o, long long *target, const char *msg) { int getLongLongFromObjectOrReply(client *c, robj *o, long long *target, const char *msg) {
long long value; long long value;
if (getLongLongFromObject(o, &value) != REDIS_OK) { if (getLongLongFromObject(o, &value) != REDIS_OK) {
if (msg != NULL) { if (msg != NULL) {
...@@ -652,7 +652,7 @@ int getLongLongFromObjectOrReply(redisClient *c, robj *o, long long *target, con ...@@ -652,7 +652,7 @@ int getLongLongFromObjectOrReply(redisClient *c, robj *o, long long *target, con
return REDIS_OK; return REDIS_OK;
} }
int getLongFromObjectOrReply(redisClient *c, robj *o, long *target, const char *msg) { int getLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg) {
long long value; long long value;
if (getLongLongFromObjectOrReply(c, o, &value, msg) != REDIS_OK) return REDIS_ERR; if (getLongLongFromObjectOrReply(c, o, &value, msg) != REDIS_OK) return REDIS_ERR;
...@@ -696,14 +696,14 @@ unsigned long long estimateObjectIdleTime(robj *o) { ...@@ -696,14 +696,14 @@ unsigned long long estimateObjectIdleTime(robj *o) {
/* This is a helper function for the OBJECT command. We need to lookup keys /* This is a helper function for the OBJECT command. We need to lookup keys
* without any modification of LRU or other parameters. */ * without any modification of LRU or other parameters. */
robj *objectCommandLookup(redisClient *c, robj *key) { robj *objectCommandLookup(client *c, robj *key) {
dictEntry *de; dictEntry *de;
if ((de = dictFind(c->db->dict,key->ptr)) == NULL) return NULL; if ((de = dictFind(c->db->dict,key->ptr)) == NULL) return NULL;
return (robj*) dictGetVal(de); return (robj*) dictGetVal(de);
} }
robj *objectCommandLookupOrReply(redisClient *c, robj *key, robj *reply) { robj *objectCommandLookupOrReply(client *c, robj *key, robj *reply) {
robj *o = objectCommandLookup(c,key); robj *o = objectCommandLookup(c,key);
if (!o) addReply(c, reply); if (!o) addReply(c, reply);
...@@ -712,7 +712,7 @@ robj *objectCommandLookupOrReply(redisClient *c, robj *key, robj *reply) { ...@@ -712,7 +712,7 @@ robj *objectCommandLookupOrReply(redisClient *c, robj *key, robj *reply) {
/* Object command allows to inspect the internals of an Redis Object. /* Object command allows to inspect the internals of an Redis Object.
* Usage: OBJECT <refcount|encoding|idletime> <key> */ * Usage: OBJECT <refcount|encoding|idletime> <key> */
void objectCommand(redisClient *c) { void objectCommand(client *c) {
robj *o; robj *o;
if (!strcasecmp(c->argv[1]->ptr,"refcount") && c->argc == 3) { if (!strcasecmp(c->argv[1]->ptr,"refcount") && c->argc == 3) {
......
...@@ -48,14 +48,14 @@ int listMatchPubsubPattern(void *a, void *b) { ...@@ -48,14 +48,14 @@ int listMatchPubsubPattern(void *a, void *b) {
} }
/* Return the number of channels + patterns a client is subscribed to. */ /* Return the number of channels + patterns a client is subscribed to. */
int clientSubscriptionsCount(redisClient *c) { int clientSubscriptionsCount(client *c) {
return dictSize(c->pubsub_channels)+ return dictSize(c->pubsub_channels)+
listLength(c->pubsub_patterns); listLength(c->pubsub_patterns);
} }
/* Subscribe a client to a channel. Returns 1 if the operation succeeded, or /* Subscribe a client to a channel. Returns 1 if the operation succeeded, or
* 0 if the client was already subscribed to that channel. */ * 0 if the client was already subscribed to that channel. */
int pubsubSubscribeChannel(redisClient *c, robj *channel) { int pubsubSubscribeChannel(client *c, robj *channel) {
dictEntry *de; dictEntry *de;
list *clients = NULL; list *clients = NULL;
int retval = 0; int retval = 0;
...@@ -85,7 +85,7 @@ int pubsubSubscribeChannel(redisClient *c, robj *channel) { ...@@ -85,7 +85,7 @@ int pubsubSubscribeChannel(redisClient *c, robj *channel) {
/* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or /* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or
* 0 if the client was not subscribed to the specified channel. */ * 0 if the client was not subscribed to the specified channel. */
int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) { int pubsubUnsubscribeChannel(client *c, robj *channel, int notify) {
dictEntry *de; dictEntry *de;
list *clients; list *clients;
listNode *ln; listNode *ln;
...@@ -124,7 +124,7 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) { ...@@ -124,7 +124,7 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
} }
/* Subscribe a client to a pattern. Returns 1 if the operation succeeded, or 0 if the client was already subscribed to that pattern. */ /* Subscribe a client to a pattern. Returns 1 if the operation succeeded, or 0 if the client was already subscribed to that pattern. */
int pubsubSubscribePattern(redisClient *c, robj *pattern) { int pubsubSubscribePattern(client *c, robj *pattern) {
int retval = 0; int retval = 0;
if (listSearchKey(c->pubsub_patterns,pattern) == NULL) { if (listSearchKey(c->pubsub_patterns,pattern) == NULL) {
...@@ -147,7 +147,7 @@ int pubsubSubscribePattern(redisClient *c, robj *pattern) { ...@@ -147,7 +147,7 @@ int pubsubSubscribePattern(redisClient *c, robj *pattern) {
/* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or /* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or
* 0 if the client was not subscribed to the specified channel. */ * 0 if the client was not subscribed to the specified channel. */
int pubsubUnsubscribePattern(redisClient *c, robj *pattern, int notify) { int pubsubUnsubscribePattern(client *c, robj *pattern, int notify) {
listNode *ln; listNode *ln;
pubsubPattern pat; pubsubPattern pat;
int retval = 0; int retval = 0;
...@@ -175,7 +175,7 @@ int pubsubUnsubscribePattern(redisClient *c, robj *pattern, int notify) { ...@@ -175,7 +175,7 @@ int pubsubUnsubscribePattern(redisClient *c, robj *pattern, int notify) {
/* Unsubscribe from all the channels. Return the number of channels the /* Unsubscribe from all the channels. Return the number of channels the
* client was subscribed to. */ * client was subscribed to. */
int pubsubUnsubscribeAllChannels(redisClient *c, int notify) { int pubsubUnsubscribeAllChannels(client *c, int notify) {
dictIterator *di = dictGetSafeIterator(c->pubsub_channels); dictIterator *di = dictGetSafeIterator(c->pubsub_channels);
dictEntry *de; dictEntry *de;
int count = 0; int count = 0;
...@@ -199,7 +199,7 @@ int pubsubUnsubscribeAllChannels(redisClient *c, int notify) { ...@@ -199,7 +199,7 @@ int pubsubUnsubscribeAllChannels(redisClient *c, int notify) {
/* Unsubscribe from all the patterns. Return the number of patterns the /* Unsubscribe from all the patterns. Return the number of patterns the
* client was subscribed from. */ * client was subscribed from. */
int pubsubUnsubscribeAllPatterns(redisClient *c, int notify) { int pubsubUnsubscribeAllPatterns(client *c, int notify) {
listNode *ln; listNode *ln;
listIter li; listIter li;
int count = 0; int count = 0;
...@@ -237,7 +237,7 @@ int pubsubPublishMessage(robj *channel, robj *message) { ...@@ -237,7 +237,7 @@ int pubsubPublishMessage(robj *channel, robj *message) {
listRewind(list,&li); listRewind(list,&li);
while ((ln = listNext(&li)) != NULL) { while ((ln = listNext(&li)) != NULL) {
redisClient *c = ln->value; client *c = ln->value;
addReply(c,shared.mbulkhdr[3]); addReply(c,shared.mbulkhdr[3]);
addReply(c,shared.messagebulk); addReply(c,shared.messagebulk);
...@@ -274,7 +274,7 @@ int pubsubPublishMessage(robj *channel, robj *message) { ...@@ -274,7 +274,7 @@ int pubsubPublishMessage(robj *channel, robj *message) {
* Pubsub commands implementation * Pubsub commands implementation
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void subscribeCommand(redisClient *c) { void subscribeCommand(client *c) {
int j; int j;
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
...@@ -282,7 +282,7 @@ void subscribeCommand(redisClient *c) { ...@@ -282,7 +282,7 @@ void subscribeCommand(redisClient *c) {
c->flags |= REDIS_PUBSUB; c->flags |= REDIS_PUBSUB;
} }
void unsubscribeCommand(redisClient *c) { void unsubscribeCommand(client *c) {
if (c->argc == 1) { if (c->argc == 1) {
pubsubUnsubscribeAllChannels(c,1); pubsubUnsubscribeAllChannels(c,1);
} else { } else {
...@@ -294,7 +294,7 @@ void unsubscribeCommand(redisClient *c) { ...@@ -294,7 +294,7 @@ void unsubscribeCommand(redisClient *c) {
if (clientSubscriptionsCount(c) == 0) c->flags &= ~REDIS_PUBSUB; if (clientSubscriptionsCount(c) == 0) c->flags &= ~REDIS_PUBSUB;
} }
void psubscribeCommand(redisClient *c) { void psubscribeCommand(client *c) {
int j; int j;
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
...@@ -302,7 +302,7 @@ void psubscribeCommand(redisClient *c) { ...@@ -302,7 +302,7 @@ void psubscribeCommand(redisClient *c) {
c->flags |= REDIS_PUBSUB; c->flags |= REDIS_PUBSUB;
} }
void punsubscribeCommand(redisClient *c) { void punsubscribeCommand(client *c) {
if (c->argc == 1) { if (c->argc == 1) {
pubsubUnsubscribeAllPatterns(c,1); pubsubUnsubscribeAllPatterns(c,1);
} else { } else {
...@@ -314,7 +314,7 @@ void punsubscribeCommand(redisClient *c) { ...@@ -314,7 +314,7 @@ void punsubscribeCommand(redisClient *c) {
if (clientSubscriptionsCount(c) == 0) c->flags &= ~REDIS_PUBSUB; if (clientSubscriptionsCount(c) == 0) c->flags &= ~REDIS_PUBSUB;
} }
void publishCommand(redisClient *c) { void publishCommand(client *c) {
int receivers = pubsubPublishMessage(c->argv[1],c->argv[2]); int receivers = pubsubPublishMessage(c->argv[1],c->argv[2]);
if (server.cluster_enabled) if (server.cluster_enabled)
clusterPropagatePublish(c->argv[1],c->argv[2]); clusterPropagatePublish(c->argv[1],c->argv[2]);
...@@ -324,7 +324,7 @@ void publishCommand(redisClient *c) { ...@@ -324,7 +324,7 @@ void publishCommand(redisClient *c) {
} }
/* PUBSUB command for Pub/Sub introspection. */ /* PUBSUB command for Pub/Sub introspection. */
void pubsubCommand(redisClient *c) { void pubsubCommand(client *c) {
if (!strcasecmp(c->argv[1]->ptr,"channels") && if (!strcasecmp(c->argv[1]->ptr,"channels") &&
(c->argc == 2 || c->argc ==3)) (c->argc == 2 || c->argc ==3))
{ {
......
...@@ -1482,7 +1482,7 @@ void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) { ...@@ -1482,7 +1482,7 @@ void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_END) { if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_END) {
uint64_t j; uint64_t j;
...@@ -1566,7 +1566,7 @@ int rdbSaveToSlavesSockets(void) { ...@@ -1566,7 +1566,7 @@ int rdbSaveToSlavesSockets(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) { if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) {
clientids[numfds] = slave->id; clientids[numfds] = slave->id;
...@@ -1672,7 +1672,7 @@ int rdbSaveToSlavesSockets(void) { ...@@ -1672,7 +1672,7 @@ int rdbSaveToSlavesSockets(void) {
return REDIS_OK; /* unreached */ return REDIS_OK; /* unreached */
} }
void saveCommand(redisClient *c) { void saveCommand(client *c) {
if (server.rdb_child_pid != -1) { if (server.rdb_child_pid != -1) {
addReplyError(c,"Background save already in progress"); addReplyError(c,"Background save already in progress");
return; return;
...@@ -1684,7 +1684,7 @@ void saveCommand(redisClient *c) { ...@@ -1684,7 +1684,7 @@ void saveCommand(redisClient *c) {
} }
} }
void bgsaveCommand(redisClient *c) { void bgsaveCommand(client *c) {
if (server.rdb_child_pid != -1) { if (server.rdb_child_pid != -1) {
addReplyError(c,"Background save already in progress"); addReplyError(c,"Background save already in progress");
} else if (server.aof_child_pid != -1) { } else if (server.aof_child_pid != -1) {
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
void replicationDiscardCachedMaster(void); void replicationDiscardCachedMaster(void);
void replicationResurrectCachedMaster(int newfd); void replicationResurrectCachedMaster(int newfd);
void replicationSendAck(void); void replicationSendAck(void);
void putSlaveOnline(redisClient *slave); void putSlaveOnline(client *slave);
/* --------------------------- Utility functions ---------------------------- */ /* --------------------------- Utility functions ---------------------------- */
...@@ -48,7 +48,7 @@ void putSlaveOnline(redisClient *slave); ...@@ -48,7 +48,7 @@ void putSlaveOnline(redisClient *slave);
* pair. Mostly useful for logging, since we want to log a slave using its * pair. Mostly useful for logging, since we want to log a slave using its
* IP address and it's listening port which is more clear for the user, for * IP address and it's listening port which is more clear for the user, for
* example: "Closing connection with slave 10.1.2.3:6380". */ * example: "Closing connection with slave 10.1.2.3:6380". */
char *replicationGetSlaveName(redisClient *c) { char *replicationGetSlaveName(client *c) {
static char buf[REDIS_PEER_ID_LEN]; static char buf[REDIS_PEER_ID_LEN];
char ip[REDIS_IP_STR_LEN]; char ip[REDIS_IP_STR_LEN];
...@@ -200,7 +200,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) { ...@@ -200,7 +200,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
/* Send it to slaves. */ /* Send it to slaves. */
listRewind(slaves,&li); listRewind(slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
addReply(slave,selectcmd); addReply(slave,selectcmd);
} }
...@@ -239,7 +239,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) { ...@@ -239,7 +239,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
/* Write the command to every slave. */ /* Write the command to every slave. */
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
/* Don't feed slaves that are still waiting for BGSAVE to start */ /* Don't feed slaves that are still waiting for BGSAVE to start */
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) continue; if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) continue;
...@@ -258,7 +258,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) { ...@@ -258,7 +258,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
} }
} }
void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **argv, int argc) { void replicationFeedMonitors(client *c, list *monitors, int dictid, robj **argv, int argc) {
listNode *ln; listNode *ln;
listIter li; listIter li;
int j; int j;
...@@ -291,7 +291,7 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj ** ...@@ -291,7 +291,7 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **
listRewind(monitors,&li); listRewind(monitors,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *monitor = ln->value; client *monitor = ln->value;
addReply(monitor,cmdobj); addReply(monitor,cmdobj);
} }
decrRefCount(cmdobj); decrRefCount(cmdobj);
...@@ -299,7 +299,7 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj ** ...@@ -299,7 +299,7 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **
/* Feed the slave 'c' with the replication backlog starting from the /* Feed the slave 'c' with the replication backlog starting from the
* specified 'offset' up to the end of the backlog. */ * specified 'offset' up to the end of the backlog. */
long long addReplyReplicationBacklog(redisClient *c, long long offset) { long long addReplyReplicationBacklog(client *c, long long offset) {
long long j, skip, len; long long j, skip, len;
serverLog(REDIS_DEBUG, "[PSYNC] Slave request offset: %lld", offset); serverLog(REDIS_DEBUG, "[PSYNC] Slave request offset: %lld", offset);
...@@ -354,7 +354,7 @@ long long addReplyReplicationBacklog(redisClient *c, long long offset) { ...@@ -354,7 +354,7 @@ long long addReplyReplicationBacklog(redisClient *c, long long offset) {
* *
* On success return REDIS_OK, otherwise REDIS_ERR is returned and we proceed * On success return REDIS_OK, otherwise REDIS_ERR is returned and we proceed
* with the usual full resync. */ * with the usual full resync. */
int masterTryPartialResynchronization(redisClient *c) { int masterTryPartialResynchronization(client *c) {
long long psync_offset, psync_len; long long psync_offset, psync_len;
char *master_runid = c->argv[1]->ptr; char *master_runid = c->argv[1]->ptr;
char buf[128]; char buf[128];
...@@ -460,7 +460,7 @@ int startBgsaveForReplication(void) { ...@@ -460,7 +460,7 @@ int startBgsaveForReplication(void) {
} }
/* SYNC and PSYNC command implemenation. */ /* SYNC and PSYNC command implemenation. */
void syncCommand(redisClient *c) { void syncCommand(client *c) {
/* ignore SYNC if already slave or in monitor mode */ /* ignore SYNC if already slave or in monitor mode */
if (c->flags & REDIS_SLAVE) return; if (c->flags & REDIS_SLAVE) return;
...@@ -523,7 +523,7 @@ void syncCommand(redisClient *c) { ...@@ -523,7 +523,7 @@ void syncCommand(redisClient *c) {
/* Ok a background save is in progress. Let's check if it is a good /* Ok a background save is in progress. Let's check if it is a good
* one for replication, i.e. if there is another slave that is * one for replication, i.e. if there is another slave that is
* registering differences since the server forked to save. */ * registering differences since the server forked to save. */
redisClient *slave; client *slave;
listNode *ln; listNode *ln;
listIter li; listIter li;
...@@ -594,7 +594,7 @@ void syncCommand(redisClient *c) { ...@@ -594,7 +594,7 @@ void syncCommand(redisClient *c) {
* In the future the same command can be used in order to configure * In the future the same command can be used in order to configure
* the replication to initiate an incremental replication instead of a * the replication to initiate an incremental replication instead of a
* full resync. */ * full resync. */
void replconfCommand(redisClient *c) { void replconfCommand(client *c) {
int j; int j;
if ((c->argc % 2) == 0) { if ((c->argc % 2) == 0) {
...@@ -658,7 +658,7 @@ void replconfCommand(redisClient *c) { ...@@ -658,7 +658,7 @@ void replconfCommand(redisClient *c) {
* command disables it, so that we can accumulate output buffer without * command disables it, so that we can accumulate output buffer without
* sending it to the slave. * sending it to the slave.
* 3) Update the count of good slaves. */ * 3) Update the count of good slaves. */
void putSlaveOnline(redisClient *slave) { void putSlaveOnline(client *slave) {
slave->replstate = REDIS_REPL_ONLINE; slave->replstate = REDIS_REPL_ONLINE;
slave->repl_put_online_on_ack = 0; slave->repl_put_online_on_ack = 0;
slave->repl_ack_time = server.unixtime; /* Prevent false timeout. */ slave->repl_ack_time = server.unixtime; /* Prevent false timeout. */
...@@ -674,7 +674,7 @@ void putSlaveOnline(redisClient *slave) { ...@@ -674,7 +674,7 @@ void putSlaveOnline(redisClient *slave) {
} }
void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) { void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
redisClient *slave = privdata; client *slave = privdata;
REDIS_NOTUSED(el); REDIS_NOTUSED(el);
REDIS_NOTUSED(mask); REDIS_NOTUSED(mask);
char buf[REDIS_IOBUF_LEN]; char buf[REDIS_IOBUF_LEN];
...@@ -750,7 +750,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) { ...@@ -750,7 +750,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) { if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) {
startbgsave = 1; startbgsave = 1;
...@@ -808,7 +808,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) { ...@@ -808,7 +808,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
serverLog(REDIS_WARNING,"SYNC failed. BGSAVE failed"); serverLog(REDIS_WARNING,"SYNC failed. BGSAVE failed");
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START)
freeClient(slave); freeClient(slave);
...@@ -1477,7 +1477,7 @@ void replicationUnsetMaster(void) { ...@@ -1477,7 +1477,7 @@ void replicationUnsetMaster(void) {
server.repl_state = REDIS_REPL_NONE; server.repl_state = REDIS_REPL_NONE;
} }
void slaveofCommand(redisClient *c) { void slaveofCommand(client *c) {
/* SLAVEOF is not allowed in cluster mode as replication is automatically /* SLAVEOF is not allowed in cluster mode as replication is automatically
* configured using the current address of the master node. */ * configured using the current address of the master node. */
if (server.cluster_enabled) { if (server.cluster_enabled) {
...@@ -1518,7 +1518,7 @@ void slaveofCommand(redisClient *c) { ...@@ -1518,7 +1518,7 @@ void slaveofCommand(redisClient *c) {
/* ROLE command: provide information about the role of the instance /* ROLE command: provide information about the role of the instance
* (master or slave) and additional information related to replication * (master or slave) and additional information related to replication
* in an easy to process format. */ * in an easy to process format. */
void roleCommand(redisClient *c) { void roleCommand(client *c) {
if (server.masterhost == NULL) { if (server.masterhost == NULL) {
listIter li; listIter li;
listNode *ln; listNode *ln;
...@@ -1531,7 +1531,7 @@ void roleCommand(redisClient *c) { ...@@ -1531,7 +1531,7 @@ void roleCommand(redisClient *c) {
mbcount = addDeferredMultiBulkLength(c); mbcount = addDeferredMultiBulkLength(c);
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
char ip[REDIS_IP_STR_LEN]; char ip[REDIS_IP_STR_LEN];
if (anetPeerToString(slave->fd,ip,sizeof(ip),NULL) == -1) continue; if (anetPeerToString(slave->fd,ip,sizeof(ip),NULL) == -1) continue;
...@@ -1568,7 +1568,7 @@ void roleCommand(redisClient *c) { ...@@ -1568,7 +1568,7 @@ void roleCommand(redisClient *c) {
* processed offset. If we are not connected with a master, the command has * processed offset. If we are not connected with a master, the command has
* no effects. */ * no effects. */
void replicationSendAck(void) { void replicationSendAck(void) {
redisClient *c = server.master; client *c = server.master;
if (c != NULL) { if (c != NULL) {
c->flags |= REDIS_MASTER_FORCE_REPLY; c->flags |= REDIS_MASTER_FORCE_REPLY;
...@@ -1600,7 +1600,7 @@ void replicationSendAck(void) { ...@@ -1600,7 +1600,7 @@ void replicationSendAck(void) {
* replicationResurrectCachedMaster() that is used after a successful PSYNC * replicationResurrectCachedMaster() that is used after a successful PSYNC
* handshake in order to reactivate the cached master. * handshake in order to reactivate the cached master.
*/ */
void replicationCacheMaster(redisClient *c) { void replicationCacheMaster(client *c) {
listNode *ln; listNode *ln;
redisAssert(server.master != NULL && server.cached_master == NULL); redisAssert(server.master != NULL && server.cached_master == NULL);
...@@ -1697,7 +1697,7 @@ void refreshGoodSlavesCount(void) { ...@@ -1697,7 +1697,7 @@ void refreshGoodSlavesCount(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
time_t lag = server.unixtime - slave->repl_ack_time; time_t lag = server.unixtime - slave->repl_ack_time;
if (slave->replstate == REDIS_REPL_ONLINE && if (slave->replstate == REDIS_REPL_ONLINE &&
...@@ -1833,7 +1833,7 @@ int replicationCountAcksByOffset(long long offset) { ...@@ -1833,7 +1833,7 @@ int replicationCountAcksByOffset(long long offset) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate != REDIS_REPL_ONLINE) continue; if (slave->replstate != REDIS_REPL_ONLINE) continue;
if (slave->repl_ack_off >= offset) count++; if (slave->repl_ack_off >= offset) count++;
...@@ -1843,7 +1843,7 @@ int replicationCountAcksByOffset(long long offset) { ...@@ -1843,7 +1843,7 @@ int replicationCountAcksByOffset(long long offset) {
/* WAIT for N replicas to acknowledge the processing of our latest /* WAIT for N replicas to acknowledge the processing of our latest
* write command (and all the previous commands). */ * write command (and all the previous commands). */
void waitCommand(redisClient *c) { void waitCommand(client *c) {
mstime_t timeout; mstime_t timeout;
long numreplicas, ackreplicas; long numreplicas, ackreplicas;
long long offset = c->woff; long long offset = c->woff;
...@@ -1878,7 +1878,7 @@ void waitCommand(redisClient *c) { ...@@ -1878,7 +1878,7 @@ void waitCommand(redisClient *c) {
* specific cleanup. We just remove the client from the list of clients * specific cleanup. We just remove the client from the list of clients
* waiting for replica acks. Never call it directly, call unblockClient() * waiting for replica acks. Never call it directly, call unblockClient()
* instead. */ * instead. */
void unblockClientWaitingReplicas(redisClient *c) { void unblockClientWaitingReplicas(client *c) {
listNode *ln = listSearchKey(server.clients_waiting_acks,c); listNode *ln = listSearchKey(server.clients_waiting_acks,c);
redisAssert(ln != NULL); redisAssert(ln != NULL);
listDelNode(server.clients_waiting_acks,ln); listDelNode(server.clients_waiting_acks,ln);
...@@ -1895,7 +1895,7 @@ void processClientsWaitingReplicas(void) { ...@@ -1895,7 +1895,7 @@ void processClientsWaitingReplicas(void) {
listRewind(server.clients_waiting_acks,&li); listRewind(server.clients_waiting_acks,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *c = ln->value; client *c = ln->value;
/* Every time we find a client that is satisfied for a given /* Every time we find a client that is satisfied for a given
* offset and number of replicas, we remember it so the next client * offset and number of replicas, we remember it so the next client
...@@ -2005,7 +2005,7 @@ void replicationCron(void) { ...@@ -2005,7 +2005,7 @@ void replicationCron(void) {
* last-io timer preventing a timeout. */ * last-io timer preventing a timeout. */
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START || if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START ||
(slave->replstate == REDIS_REPL_WAIT_BGSAVE_END && (slave->replstate == REDIS_REPL_WAIT_BGSAVE_END &&
...@@ -2025,7 +2025,7 @@ void replicationCron(void) { ...@@ -2025,7 +2025,7 @@ void replicationCron(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate != REDIS_REPL_ONLINE) continue; if (slave->replstate != REDIS_REPL_ONLINE) continue;
if (slave->flags & REDIS_PRE_PSYNC) continue; if (slave->flags & REDIS_PRE_PSYNC) continue;
...@@ -2079,7 +2079,7 @@ void replicationCron(void) { ...@@ -2079,7 +2079,7 @@ void replicationCron(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) { if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) {
idle = server.unixtime - slave->lastinteraction; idle = server.unixtime - slave->lastinteraction;
if (idle > max_idle) max_idle = idle; if (idle > max_idle) max_idle = idle;
...@@ -2098,7 +2098,7 @@ void replicationCron(void) { ...@@ -2098,7 +2098,7 @@ void replicationCron(void) {
* startBgsaveForReplication(). */ * startBgsaveForReplication(). */
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = ln->value; client *slave = ln->value;
if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START) if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_START)
slave->replstate = REDIS_REPL_WAIT_BGSAVE_END; slave->replstate = REDIS_REPL_WAIT_BGSAVE_END;
} }
......
...@@ -206,7 +206,7 @@ void luaSortArray(lua_State *lua) { ...@@ -206,7 +206,7 @@ void luaSortArray(lua_State *lua) {
int luaRedisGenericCommand(lua_State *lua, int raise_error) { int luaRedisGenericCommand(lua_State *lua, int raise_error) {
int j, argc = lua_gettop(lua); int j, argc = lua_gettop(lua);
struct redisCommand *cmd; struct redisCommand *cmd;
redisClient *c = server.lua_client; client *c = server.lua_client;
sds reply; sds reply;
/* Cached across calls. */ /* Cached across calls. */
...@@ -798,7 +798,7 @@ void sha1hex(char *digest, char *script, size_t len) { ...@@ -798,7 +798,7 @@ void sha1hex(char *digest, char *script, size_t len) {
digest[40] = '\0'; digest[40] = '\0';
} }
void luaReplyToRedisReply(redisClient *c, lua_State *lua) { void luaReplyToRedisReply(client *c, lua_State *lua) {
int t = lua_type(lua,-1); int t = lua_type(lua,-1);
switch(t) { switch(t) {
...@@ -884,7 +884,7 @@ void luaSetGlobalArray(lua_State *lua, char *var, robj **elev, int elec) { ...@@ -884,7 +884,7 @@ void luaSetGlobalArray(lua_State *lua, char *var, robj **elev, int elec) {
* On success REDIS_OK is returned, and nothing is left on the Lua stack. * On success REDIS_OK is returned, and nothing is left on the Lua stack.
* On error REDIS_ERR is returned and an appropriate error is set in the * On error REDIS_ERR is returned and an appropriate error is set in the
* client context. */ * client context. */
int luaCreateFunction(redisClient *c, lua_State *lua, char *funcname, robj *body) { int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) {
sds funcdef = sdsempty(); sds funcdef = sdsempty();
funcdef = sdscat(funcdef,"function "); funcdef = sdscat(funcdef,"function ");
...@@ -920,7 +920,7 @@ int luaCreateFunction(redisClient *c, lua_State *lua, char *funcname, robj *body ...@@ -920,7 +920,7 @@ int luaCreateFunction(redisClient *c, lua_State *lua, char *funcname, robj *body
return REDIS_OK; return REDIS_OK;
} }
void evalGenericCommand(redisClient *c, int evalsha) { void evalGenericCommand(client *c, int evalsha) {
lua_State *lua = server.lua; lua_State *lua = server.lua;
char funcname[43]; char funcname[43];
long long numkeys; long long numkeys;
...@@ -1090,11 +1090,11 @@ void evalGenericCommand(redisClient *c, int evalsha) { ...@@ -1090,11 +1090,11 @@ void evalGenericCommand(redisClient *c, int evalsha) {
} }
} }
void evalCommand(redisClient *c) { void evalCommand(client *c) {
evalGenericCommand(c,0); evalGenericCommand(c,0);
} }
void evalShaCommand(redisClient *c) { void evalShaCommand(client *c) {
if (sdslen(c->argv[1]->ptr) != 40) { if (sdslen(c->argv[1]->ptr) != 40) {
/* We know that a match is not possible if the provided SHA is /* We know that a match is not possible if the provided SHA is
* not the right length. So we return an error ASAP, this way * not the right length. So we return an error ASAP, this way
...@@ -1149,7 +1149,7 @@ int redis_math_randomseed (lua_State *L) { ...@@ -1149,7 +1149,7 @@ int redis_math_randomseed (lua_State *L) {
* SCRIPT command for script environment introspection and control * SCRIPT command for script environment introspection and control
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
void scriptCommand(redisClient *c) { void scriptCommand(client *c) {
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"flush")) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"flush")) {
scriptingReset(); scriptingReset();
addReply(c,shared.ok); addReply(c,shared.ok);
......
...@@ -416,11 +416,11 @@ dictType leaderVotesDictType = { ...@@ -416,11 +416,11 @@ dictType leaderVotesDictType = {
/* =========================== Initialization =============================== */ /* =========================== Initialization =============================== */
void sentinelCommand(redisClient *c); void sentinelCommand(client *c);
void sentinelInfoCommand(redisClient *c); void sentinelInfoCommand(client *c);
void sentinelSetCommand(redisClient *c); void sentinelSetCommand(client *c);
void sentinelPublishCommand(redisClient *c); void sentinelPublishCommand(client *c);
void sentinelRoleCommand(redisClient *c); void sentinelRoleCommand(client *c);
struct redisCommand sentinelcmds[] = { struct redisCommand sentinelcmds[] = {
{"ping",pingCommand,1,"",0,NULL,0,0,0,0,0}, {"ping",pingCommand,1,"",0,NULL,0,0,0,0,0},
...@@ -859,7 +859,7 @@ void sentinelKillTimedoutScripts(void) { ...@@ -859,7 +859,7 @@ void sentinelKillTimedoutScripts(void) {
} }
/* Implements SENTINEL PENDING-SCRIPTS command. */ /* Implements SENTINEL PENDING-SCRIPTS command. */
void sentinelPendingScriptsCommand(redisClient *c) { void sentinelPendingScriptsCommand(client *c) {
listNode *ln; listNode *ln;
listIter li; listIter li;
...@@ -2604,7 +2604,7 @@ const char *sentinelFailoverStateStr(int state) { ...@@ -2604,7 +2604,7 @@ const char *sentinelFailoverStateStr(int state) {
} }
/* Redis instance to Redis protocol representation. */ /* Redis instance to Redis protocol representation. */
void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) { void addReplySentinelRedisInstance(client *c, sentinelRedisInstance *ri) {
char *flags = sdsempty(); char *flags = sdsempty();
void *mbl; void *mbl;
int fields = 0; int fields = 0;
...@@ -2795,7 +2795,7 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) { ...@@ -2795,7 +2795,7 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
/* Output a number of instances contained inside a dictionary as /* Output a number of instances contained inside a dictionary as
* Redis protocol. */ * Redis protocol. */
void addReplyDictOfRedisInstances(redisClient *c, dict *instances) { void addReplyDictOfRedisInstances(client *c, dict *instances) {
dictIterator *di; dictIterator *di;
dictEntry *de; dictEntry *de;
...@@ -2812,7 +2812,7 @@ void addReplyDictOfRedisInstances(redisClient *c, dict *instances) { ...@@ -2812,7 +2812,7 @@ void addReplyDictOfRedisInstances(redisClient *c, dict *instances) {
/* Lookup the named master into sentinel.masters. /* Lookup the named master into sentinel.masters.
* If the master is not found reply to the client with an error and returns * If the master is not found reply to the client with an error and returns
* NULL. */ * NULL. */
sentinelRedisInstance *sentinelGetMasterByNameOrReplyError(redisClient *c, sentinelRedisInstance *sentinelGetMasterByNameOrReplyError(client *c,
robj *name) robj *name)
{ {
sentinelRedisInstance *ri; sentinelRedisInstance *ri;
...@@ -2850,7 +2850,7 @@ int sentinelIsQuorumReachable(sentinelRedisInstance *master, int *usableptr) { ...@@ -2850,7 +2850,7 @@ int sentinelIsQuorumReachable(sentinelRedisInstance *master, int *usableptr) {
return result; return result;
} }
void sentinelCommand(redisClient *c) { void sentinelCommand(client *c) {
if (!strcasecmp(c->argv[1]->ptr,"masters")) { if (!strcasecmp(c->argv[1]->ptr,"masters")) {
/* SENTINEL MASTERS */ /* SENTINEL MASTERS */
if (c->argc != 2) goto numargserr; if (c->argc != 2) goto numargserr;
...@@ -3166,7 +3166,7 @@ numargserr: ...@@ -3166,7 +3166,7 @@ numargserr:
} }
/* SENTINEL INFO [section] */ /* SENTINEL INFO [section] */
void sentinelInfoCommand(redisClient *c) { void sentinelInfoCommand(client *c) {
if (c->argc > 2) { if (c->argc > 2) {
addReply(c,shared.syntaxerr); addReply(c,shared.syntaxerr);
return; return;
...@@ -3232,7 +3232,7 @@ void sentinelInfoCommand(redisClient *c) { ...@@ -3232,7 +3232,7 @@ void sentinelInfoCommand(redisClient *c) {
/* Implements Sentinel verison of the ROLE command. The output is /* Implements Sentinel verison of the ROLE command. The output is
* "sentinel" and the list of currently monitored master names. */ * "sentinel" and the list of currently monitored master names. */
void sentinelRoleCommand(redisClient *c) { void sentinelRoleCommand(client *c) {
dictIterator *di; dictIterator *di;
dictEntry *de; dictEntry *de;
...@@ -3250,7 +3250,7 @@ void sentinelRoleCommand(redisClient *c) { ...@@ -3250,7 +3250,7 @@ void sentinelRoleCommand(redisClient *c) {
} }
/* SENTINEL SET <mastername> [<option> <value> ...] */ /* SENTINEL SET <mastername> [<option> <value> ...] */
void sentinelSetCommand(redisClient *c) { void sentinelSetCommand(client *c) {
sentinelRedisInstance *ri; sentinelRedisInstance *ri;
int j, changes = 0; int j, changes = 0;
char *option, *value; char *option, *value;
...@@ -3343,7 +3343,7 @@ badfmt: /* Bad format errors */ ...@@ -3343,7 +3343,7 @@ badfmt: /* Bad format errors */
* *
* Because we have a Sentinel PUBLISH, the code to send hello messages is the same * Because we have a Sentinel PUBLISH, the code to send hello messages is the same
* for all the three kind of instances: masters, slaves, sentinels. */ * for all the three kind of instances: masters, slaves, sentinels. */
void sentinelPublishCommand(redisClient *c) { void sentinelPublishCommand(client *c) {
if (strcmp(c->argv[1]->ptr,SENTINEL_HELLO_CHANNEL)) { if (strcmp(c->argv[1]->ptr,SENTINEL_HELLO_CHANNEL)) {
addReplyError(c, "Only HELLO messages are accepted by Sentinel instances."); addReplyError(c, "Only HELLO messages are accepted by Sentinel instances.");
return; return;
......
...@@ -915,7 +915,7 @@ long long getInstantaneousMetric(int metric) { ...@@ -915,7 +915,7 @@ long long getInstantaneousMetric(int metric) {
* The function gets the current time in milliseconds as argument since * The function gets the current time in milliseconds as argument since
* it gets called multiple times in a loop, so calling gettimeofday() for * it gets called multiple times in a loop, so calling gettimeofday() for
* each iteration would be costly without any actual gain. */ * each iteration would be costly without any actual gain. */
int clientsCronHandleTimeout(redisClient *c, mstime_t now_ms) { int clientsCronHandleTimeout(client *c, mstime_t now_ms) {
time_t now = now_ms/1000; time_t now = now_ms/1000;
if (server.maxidletime && if (server.maxidletime &&
...@@ -951,7 +951,7 @@ int clientsCronHandleTimeout(redisClient *c, mstime_t now_ms) { ...@@ -951,7 +951,7 @@ int clientsCronHandleTimeout(redisClient *c, mstime_t now_ms) {
* free space not used, this function reclaims space if needed. * free space not used, this function reclaims space if needed.
* *
* The function always returns 0 as it never terminates the client. */ * The function always returns 0 as it never terminates the client. */
int clientsCronResizeQueryBuffer(redisClient *c) { int clientsCronResizeQueryBuffer(client *c) {
size_t querybuf_size = sdsAllocSize(c->querybuf); size_t querybuf_size = sdsAllocSize(c->querybuf);
time_t idletime = server.unixtime - c->lastinteraction; time_t idletime = server.unixtime - c->lastinteraction;
...@@ -991,7 +991,7 @@ void clientsCron(void) { ...@@ -991,7 +991,7 @@ void clientsCron(void) {
numclients : CLIENTS_CRON_MIN_ITERATIONS; numclients : CLIENTS_CRON_MIN_ITERATIONS;
while(listLength(server.clients) && iterations--) { while(listLength(server.clients) && iterations--) {
redisClient *c; client *c;
listNode *head; listNode *head;
/* Rotate the list, take the current head, process. /* Rotate the list, take the current head, process.
...@@ -2071,7 +2071,7 @@ void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, ...@@ -2071,7 +2071,7 @@ void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
/* It is possible to call the function forceCommandPropagation() inside a /* It is possible to call the function forceCommandPropagation() inside a
* Redis command implementation in order to to force the propagation of a * Redis command implementation in order to to force the propagation of a
* specific command execution into AOF / Replication. */ * specific command execution into AOF / Replication. */
void forceCommandPropagation(redisClient *c, int flags) { void forceCommandPropagation(client *c, int flags) {
if (flags & REDIS_PROPAGATE_REPL) c->flags |= REDIS_FORCE_REPL; if (flags & REDIS_PROPAGATE_REPL) c->flags |= REDIS_FORCE_REPL;
if (flags & REDIS_PROPAGATE_AOF) c->flags |= REDIS_FORCE_AOF; if (flags & REDIS_PROPAGATE_AOF) c->flags |= REDIS_FORCE_AOF;
} }
...@@ -2079,12 +2079,12 @@ void forceCommandPropagation(redisClient *c, int flags) { ...@@ -2079,12 +2079,12 @@ void forceCommandPropagation(redisClient *c, int flags) {
/* Avoid that the executed command is propagated at all. This way we /* Avoid that the executed command is propagated at all. This way we
* are free to just propagate what we want using the alsoPropagate() * are free to just propagate what we want using the alsoPropagate()
* API. */ * API. */
void preventCommandPropagation(redisClient *c) { void preventCommandPropagation(client *c) {
c->flags |= REDIS_PREVENT_PROP; c->flags |= REDIS_PREVENT_PROP;
} }
/* Call() is the core of Redis execution of a command */ /* Call() is the core of Redis execution of a command */
void call(redisClient *c, int flags) { void call(client *c, int flags) {
long long dirty, start, duration; long long dirty, start, duration;
int client_old_flags = c->flags; int client_old_flags = c->flags;
...@@ -2179,7 +2179,7 @@ void call(redisClient *c, int flags) { ...@@ -2179,7 +2179,7 @@ void call(redisClient *c, int flags) {
* If 1 is returned the client is still alive and valid and * If 1 is returned the client is still alive and valid and
* other operations can be performed by the caller. Otherwise * other operations can be performed by the caller. Otherwise
* if 0 is returned the client was destroyed (i.e. after QUIT). */ * if 0 is returned the client was destroyed (i.e. after QUIT). */
int processCommand(redisClient *c) { int processCommand(client *c) {
/* The QUIT command is handled separately. Normal command procs will /* The QUIT command is handled separately. Normal command procs will
* go through checking for replication and QUIT will cause trouble * go through checking for replication and QUIT will cause trouble
* when FORCE_REPLICATION is enabled and would be implemented in * when FORCE_REPLICATION is enabled and would be implemented in
...@@ -2476,7 +2476,7 @@ int time_independent_strcmp(char *a, char *b) { ...@@ -2476,7 +2476,7 @@ int time_independent_strcmp(char *a, char *b) {
return diff; /* If zero strings are the same. */ return diff; /* If zero strings are the same. */
} }
void authCommand(redisClient *c) { void authCommand(client *c) {
if (!server.requirepass) { if (!server.requirepass) {
addReplyError(c,"Client sent AUTH, but no password is set"); addReplyError(c,"Client sent AUTH, but no password is set");
} else if (!time_independent_strcmp(c->argv[1]->ptr, server.requirepass)) { } else if (!time_independent_strcmp(c->argv[1]->ptr, server.requirepass)) {
...@@ -2490,7 +2490,7 @@ void authCommand(redisClient *c) { ...@@ -2490,7 +2490,7 @@ void authCommand(redisClient *c) {
/* The PING command. It works in a different way if the client is in /* The PING command. It works in a different way if the client is in
* in Pub/Sub mode. */ * in Pub/Sub mode. */
void pingCommand(redisClient *c) { void pingCommand(client *c) {
/* The command takes zero or one arguments. */ /* The command takes zero or one arguments. */
if (c->argc > 2) { if (c->argc > 2) {
addReplyErrorFormat(c,"wrong number of arguments for '%s' command", addReplyErrorFormat(c,"wrong number of arguments for '%s' command",
...@@ -2513,11 +2513,11 @@ void pingCommand(redisClient *c) { ...@@ -2513,11 +2513,11 @@ void pingCommand(redisClient *c) {
} }
} }
void echoCommand(redisClient *c) { void echoCommand(client *c) {
addReplyBulk(c,c->argv[1]); addReplyBulk(c,c->argv[1]);
} }
void timeCommand(redisClient *c) { void timeCommand(client *c) {
struct timeval tv; struct timeval tv;
/* gettimeofday() can only fail if &tv is a bad address so we /* gettimeofday() can only fail if &tv is a bad address so we
...@@ -2529,7 +2529,7 @@ void timeCommand(redisClient *c) { ...@@ -2529,7 +2529,7 @@ void timeCommand(redisClient *c) {
} }
/* Helper function for addReplyCommand() to output flags. */ /* Helper function for addReplyCommand() to output flags. */
int addReplyCommandFlag(redisClient *c, struct redisCommand *cmd, int f, char *reply) { int addReplyCommandFlag(client *c, struct redisCommand *cmd, int f, char *reply) {
if (cmd->flags & f) { if (cmd->flags & f) {
addReplyStatus(c, reply); addReplyStatus(c, reply);
return 1; return 1;
...@@ -2538,7 +2538,7 @@ int addReplyCommandFlag(redisClient *c, struct redisCommand *cmd, int f, char *r ...@@ -2538,7 +2538,7 @@ int addReplyCommandFlag(redisClient *c, struct redisCommand *cmd, int f, char *r
} }
/* Output the representation of a Redis command. Used by the COMMAND command. */ /* Output the representation of a Redis command. Used by the COMMAND command. */
void addReplyCommand(redisClient *c, struct redisCommand *cmd) { void addReplyCommand(client *c, struct redisCommand *cmd) {
if (!cmd) { if (!cmd) {
addReply(c, shared.nullbulk); addReply(c, shared.nullbulk);
} else { } else {
...@@ -2575,7 +2575,7 @@ void addReplyCommand(redisClient *c, struct redisCommand *cmd) { ...@@ -2575,7 +2575,7 @@ void addReplyCommand(redisClient *c, struct redisCommand *cmd) {
} }
/* COMMAND <subcommand> <args> */ /* COMMAND <subcommand> <args> */
void commandCommand(redisClient *c) { void commandCommand(client *c) {
dictIterator *di; dictIterator *di;
dictEntry *de; dictEntry *de;
...@@ -3010,7 +3010,7 @@ sds genRedisInfoString(char *section) { ...@@ -3010,7 +3010,7 @@ sds genRedisInfoString(char *section) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = listNodeValue(ln); client *slave = listNodeValue(ln);
char *state = NULL; char *state = NULL;
char ip[REDIS_IP_STR_LEN]; char ip[REDIS_IP_STR_LEN];
int port; int port;
...@@ -3113,7 +3113,7 @@ sds genRedisInfoString(char *section) { ...@@ -3113,7 +3113,7 @@ sds genRedisInfoString(char *section) {
return info; return info;
} }
void infoCommand(redisClient *c) { void infoCommand(client *c) {
char *section = c->argc == 2 ? c->argv[1]->ptr : "default"; char *section = c->argc == 2 ? c->argv[1]->ptr : "default";
if (c->argc > 2) { if (c->argc > 2) {
...@@ -3123,7 +3123,7 @@ void infoCommand(redisClient *c) { ...@@ -3123,7 +3123,7 @@ void infoCommand(redisClient *c) {
addReplyBulkSds(c, genRedisInfoString(section)); addReplyBulkSds(c, genRedisInfoString(section));
} }
void monitorCommand(redisClient *c) { void monitorCommand(client *c) {
/* ignore MONITOR if already slave or in monitor mode */ /* ignore MONITOR if already slave or in monitor mode */
if (c->flags & REDIS_SLAVE) return; if (c->flags & REDIS_SLAVE) return;
...@@ -3274,7 +3274,7 @@ int freeMemoryIfNeeded(void) { ...@@ -3274,7 +3274,7 @@ int freeMemoryIfNeeded(void) {
listRewind(server.slaves,&li); listRewind(server.slaves,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
redisClient *slave = listNodeValue(ln); client *slave = listNodeValue(ln);
unsigned long obuf_bytes = getClientOutputBufferMemoryUsage(slave); unsigned long obuf_bytes = getClientOutputBufferMemoryUsage(slave);
if (obuf_bytes > mem_used) if (obuf_bytes > mem_used)
mem_used = 0; mem_used = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment