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