Skip to content

Commit 554bd0e

Browse files
committed
RDMF: use client instead of redisClient, like Disque.
1 parent 424fe9a commit 554bd0e

29 files changed

Lines changed: 619 additions & 619 deletions

src/aof.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
550550

551551
/* In Redis commands are always executed in the context of a client, so in
552552
* order to load the append only file we need to create a fake client. */
553-
struct redisClient *createFakeClient(void) {
554-
struct redisClient *c = zmalloc(sizeof(*c));
553+
struct client *createFakeClient(void) {
554+
struct client *c = zmalloc(sizeof(*c));
555555

556556
selectDb(c,0);
557557
c->fd = -1;
@@ -577,15 +577,15 @@ struct redisClient *createFakeClient(void) {
577577
return c;
578578
}
579579

580-
void freeFakeClientArgv(struct redisClient *c) {
580+
void freeFakeClientArgv(struct client *c) {
581581
int j;
582582

583583
for (j = 0; j < c->argc; j++)
584584
decrRefCount(c->argv[j]);
585585
zfree(c->argv);
586586
}
587587

588-
void freeFakeClient(struct redisClient *c) {
588+
void freeFakeClient(struct client *c) {
589589
sdsfree(c->querybuf);
590590
listRelease(c->reply);
591591
listRelease(c->watched_keys);
@@ -597,7 +597,7 @@ void freeFakeClient(struct redisClient *c) {
597597
* error (the append only file is zero-length) REDIS_ERR is returned. On
598598
* fatal error an error message is logged and the program exists. */
599599
int loadAppendOnlyFile(char *filename) {
600-
struct redisClient *fakeClient;
600+
struct client *fakeClient;
601601
FILE *fp = fopen(filename,"r");
602602
struct redis_stat sb;
603603
int old_aof_state = server.aof_state;
@@ -1297,7 +1297,7 @@ int rewriteAppendOnlyFileBackground(void) {
12971297
return REDIS_OK; /* unreached */
12981298
}
12991299

1300-
void bgrewriteaofCommand(redisClient *c) {
1300+
void bgrewriteaofCommand(client *c) {
13011301
if (server.aof_child_pid != -1) {
13021302
addReplyError(c,"Background append only file rewriting already in progress");
13031303
} else if (server.rdb_child_pid != -1) {

src/bitops.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
/* This helper function used by GETBIT / SETBIT parses the bit offset argument
3838
* making sure an error is returned if it is negative or if it overflows
3939
* Redis 512 MB limit for the string value. */
40-
static int getBitOffsetFromArgument(redisClient *c, robj *o, size_t *offset) {
40+
static int getBitOffsetFromArgument(client *c, robj *o, size_t *offset) {
4141
long long loffset;
4242
char *err = "bit offset is not an integer or out of range";
4343

@@ -209,7 +209,7 @@ long redisBitpos(void *s, unsigned long count, int bit) {
209209
#define BITOP_NOT 3
210210

211211
/* SETBIT key offset bitvalue */
212-
void setbitCommand(redisClient *c) {
212+
void setbitCommand(client *c) {
213213
robj *o;
214214
char *err = "bit is not an integer or out of range";
215215
size_t bitoffset;
@@ -256,7 +256,7 @@ void setbitCommand(redisClient *c) {
256256
}
257257

258258
/* GETBIT key offset */
259-
void getbitCommand(redisClient *c) {
259+
void getbitCommand(client *c) {
260260
robj *o;
261261
char llbuf[32];
262262
size_t bitoffset;
@@ -283,7 +283,7 @@ void getbitCommand(redisClient *c) {
283283
}
284284

285285
/* BITOP op_name target_key src_key1 src_key2 src_key3 ... src_keyN */
286-
void bitopCommand(redisClient *c) {
286+
void bitopCommand(client *c) {
287287
char *opname = c->argv[1]->ptr;
288288
robj *o, *targetkey = c->argv[2];
289289
unsigned long op, j, numkeys;
@@ -457,7 +457,7 @@ void bitopCommand(redisClient *c) {
457457
}
458458

459459
/* BITCOUNT key [start end] */
460-
void bitcountCommand(redisClient *c) {
460+
void bitcountCommand(client *c) {
461461
robj *o;
462462
long start, end, strlen;
463463
unsigned char *p;
@@ -511,7 +511,7 @@ void bitcountCommand(redisClient *c) {
511511
}
512512

513513
/* BITPOS key bit [start [end]] */
514-
void bitposCommand(redisClient *c) {
514+
void bitposCommand(client *c) {
515515
robj *o;
516516
long bit, start, end, strlen;
517517
unsigned char *p;

src/blocked.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
* Note that if the timeout is zero (usually from the point of view of
7474
* commands API this means no timeout) the value stored into 'timeout'
7575
* is zero. */
76-
int getTimeoutFromObjectOrReply(redisClient *c, robj *object, mstime_t *timeout, int unit) {
76+
int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int unit) {
7777
long long tval;
7878

7979
if (getLongLongFromObjectOrReply(c,object,&tval,
@@ -97,7 +97,7 @@ int getTimeoutFromObjectOrReply(redisClient *c, robj *object, mstime_t *timeout,
9797
/* Block a client for the specific operation type. Once the REDIS_BLOCKED
9898
* flag is set client query buffer is not longer processed, but accumulated,
9999
* and will be processed when the client is unblocked. */
100-
void blockClient(redisClient *c, int btype) {
100+
void blockClient(client *c, int btype) {
101101
c->flags |= REDIS_BLOCKED;
102102
c->btype = btype;
103103
server.bpop_blocked_clients++;
@@ -108,7 +108,7 @@ void blockClient(redisClient *c, int btype) {
108108
* unblocked after a blocking operation. */
109109
void processUnblockedClients(void) {
110110
listNode *ln;
111-
redisClient *c;
111+
client *c;
112112

113113
while (listLength(server.unblocked_clients)) {
114114
ln = listFirst(server.unblocked_clients);
@@ -131,7 +131,7 @@ void processUnblockedClients(void) {
131131

132132
/* Unblock a client calling the right function depending on the kind
133133
* of operation the client is blocking for. */
134-
void unblockClient(redisClient *c) {
134+
void unblockClient(client *c) {
135135
if (c->btype == REDIS_BLOCKED_LIST) {
136136
unblockClientWaitingData(c);
137137
} else if (c->btype == REDIS_BLOCKED_WAIT) {
@@ -154,7 +154,7 @@ void unblockClient(redisClient *c) {
154154

155155
/* This function gets called when a blocked client timed out in order to
156156
* send it a reply of some kind. */
157-
void replyToBlockedClientTimedOut(redisClient *c) {
157+
void replyToBlockedClientTimedOut(client *c) {
158158
if (c->btype == REDIS_BLOCKED_LIST) {
159159
addReply(c,shared.nullmultibulk);
160160
} else if (c->btype == REDIS_BLOCKED_WAIT) {
@@ -177,7 +177,7 @@ void disconnectAllBlockedClients(void) {
177177

178178
listRewind(server.clients,&li);
179179
while((ln = listNext(&li))) {
180-
redisClient *c = listNodeValue(ln);
180+
client *c = listNodeValue(ln);
181181

182182
if (c->flags & REDIS_BLOCKED) {
183183
addReplySds(c,sdsnew(

src/cluster.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,7 @@ sds clusterGenNodesDescription(int filter) {
37223722
* CLUSTER command
37233723
* -------------------------------------------------------------------------- */
37243724

3725-
int getSlotOrReply(redisClient *c, robj *o) {
3725+
int getSlotOrReply(client *c, robj *o) {
37263726
long long slot;
37273727

37283728
if (getLongLongFromObject(o,&slot) != REDIS_OK ||
@@ -3734,7 +3734,7 @@ int getSlotOrReply(redisClient *c, robj *o) {
37343734
return (int) slot;
37353735
}
37363736

3737-
void clusterReplyMultiBulkSlots(redisClient *c) {
3737+
void clusterReplyMultiBulkSlots(client *c) {
37383738
/* Format: 1) 1) start slot
37393739
* 2) end slot
37403740
* 3) 1) master IP
@@ -3804,7 +3804,7 @@ void clusterReplyMultiBulkSlots(redisClient *c) {
38043804
setDeferredMultiBulkLength(c, slot_replylen, num_masters);
38053805
}
38063806

3807-
void clusterCommand(redisClient *c) {
3807+
void clusterCommand(client *c) {
38083808
if (server.cluster_enabled == 0) {
38093809
addReplyError(c,"This instance has cluster support disabled");
38103810
return;
@@ -4363,7 +4363,7 @@ int verifyDumpPayload(unsigned char *p, size_t len) {
43634363
/* DUMP keyname
43644364
* DUMP is actually not used by Redis Cluster but it is the obvious
43654365
* complement of RESTORE and can be useful for different applications. */
4366-
void dumpCommand(redisClient *c) {
4366+
void dumpCommand(client *c) {
43674367
robj *o, *dumpobj;
43684368
rio payload;
43694369

@@ -4384,7 +4384,7 @@ void dumpCommand(redisClient *c) {
43844384
}
43854385

43864386
/* RESTORE key ttl serialized-value [REPLACE] */
4387-
void restoreCommand(redisClient *c) {
4387+
void restoreCommand(client *c) {
43884388
long long ttl;
43894389
rio payload;
43904390
int j, type, replace = 0;
@@ -4466,7 +4466,7 @@ typedef struct migrateCachedSocket {
44664466
* If the caller detects an error while using the socket, migrateCloseSocket()
44674467
* should be called so that the connection will be created from scratch
44684468
* the next time. */
4469-
migrateCachedSocket* migrateGetSocket(redisClient *c, robj *host, robj *port, long timeout) {
4469+
migrateCachedSocket* migrateGetSocket(client *c, robj *host, robj *port, long timeout) {
44704470
int fd;
44714471
sds name = sdsempty();
44724472
migrateCachedSocket *cs;
@@ -4558,7 +4558,7 @@ void migrateCloseTimedoutSockets(void) {
45584558
}
45594559

45604560
/* MIGRATE host port key dbid timeout [COPY | REPLACE] */
4561-
void migrateCommand(redisClient *c) {
4561+
void migrateCommand(client *c) {
45624562
migrateCachedSocket *cs;
45634563
int copy, replace, j;
45644564
long timeout;
@@ -4723,7 +4723,7 @@ void migrateCommand(redisClient *c) {
47234723
* The client should issue ASKING before to actually send the command to
47244724
* the target instance. See the Redis Cluster specification for more
47254725
* information. */
4726-
void askingCommand(redisClient *c) {
4726+
void askingCommand(client *c) {
47274727
if (server.cluster_enabled == 0) {
47284728
addReplyError(c,"This instance has cluster support disabled");
47294729
return;
@@ -4735,7 +4735,7 @@ void askingCommand(redisClient *c) {
47354735
/* The READONLY command is used by clients to enter the read-only mode.
47364736
* In this mode slaves will not redirect clients as long as clients access
47374737
* with read-only commands to keys that are served by the slave's master. */
4738-
void readonlyCommand(redisClient *c) {
4738+
void readonlyCommand(client *c) {
47394739
if (server.cluster_enabled == 0) {
47404740
addReplyError(c,"This instance has cluster support disabled");
47414741
return;
@@ -4745,7 +4745,7 @@ void readonlyCommand(redisClient *c) {
47454745
}
47464746

47474747
/* The READWRITE command just clears the READONLY command state. */
4748-
void readwriteCommand(redisClient *c) {
4748+
void readwriteCommand(client *c) {
47494749
c->flags &= ~REDIS_READONLY;
47504750
addReply(c,shared.ok);
47514751
}
@@ -4779,7 +4779,7 @@ void readwriteCommand(redisClient *c) {
47794779
* not bound to any node. In this case the cluster global state should be
47804780
* already "down" but it is fragile to rely on the update of the global state,
47814781
* so we also handle it here. */
4782-
clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) {
4782+
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) {
47834783
clusterNode *n = NULL;
47844784
robj *firstkey = NULL;
47854785
int multiple_keys = 0;
@@ -4940,7 +4940,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg
49404940
* are used, then the node 'n' should not be NULL, but should be the
49414941
* node we want to mention in the redirection. Moreover hashslot should
49424942
* be set to the hash slot that caused the redirection. */
4943-
void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int error_code) {
4943+
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code) {
49444944
if (error_code == REDIS_CLUSTER_REDIR_CROSS_SLOT) {
49454945
addReplySds(c,sdsnew("-CROSSSLOT Keys in request don't hash to the same slot\r\n"));
49464946
} else if (error_code == REDIS_CLUSTER_REDIR_UNSTABLE) {
@@ -4975,7 +4975,7 @@ void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int err
49754975
* If the client is found to be blocked into an hash slot this node no
49764976
* longer handles, the client is sent a redirection error, and the function
49774977
* returns 1. Otherwise 0 is returned and no operation is performed. */
4978-
int clusterRedirectBlockedClientIfNeeded(redisClient *c) {
4978+
int clusterRedirectBlockedClientIfNeeded(client *c) {
49794979
if (c->flags & REDIS_BLOCKED && c->btype == REDIS_BLOCKED_LIST) {
49804980
dictEntry *de;
49814981
dictIterator *di;

src/cluster.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ typedef struct {
249249
master is up. */
250250

251251
/* ---------------------- API exported outside cluster.c -------------------- */
252-
clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
253-
int clusterRedirectBlockedClientIfNeeded(redisClient *c);
254-
void clusterRedirectClient(redisClient *c, clusterNode *n, int hashslot, int error_code);
252+
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
253+
int clusterRedirectBlockedClientIfNeeded(client *c);
254+
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
255255

256256
#endif /* __REDIS_CLUSTER_H */

src/config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void loadServerConfig(char *filename, char *options) {
699699

700700
#define config_set_else } else
701701

702-
void configSetCommand(redisClient *c) {
702+
void configSetCommand(client *c) {
703703
robj *o;
704704
long long ll;
705705
int err;
@@ -1024,7 +1024,7 @@ void configSetCommand(redisClient *c) {
10241024
} \
10251025
} while(0);
10261026

1027-
void configGetCommand(redisClient *c) {
1027+
void configGetCommand(client *c) {
10281028
robj *o = c->argv[2];
10291029
void *replylen = addDeferredMultiBulkLength(c);
10301030
char *pattern = o->ptr;
@@ -1843,7 +1843,7 @@ int rewriteConfig(char *path) {
18431843
* CONFIG command entry point
18441844
*----------------------------------------------------------------------------*/
18451845

1846-
void configCommand(redisClient *c) {
1846+
void configCommand(client *c) {
18471847
if (!strcasecmp(c->argv[1]->ptr,"set")) {
18481848
if (c->argc != 4) goto badarity;
18491849
configSetCommand(c);

0 commit comments

Comments
 (0)