Rename 'redis' to 'server' and redisNodeFlags to clusterNodeFlags (#191)

Rename additional instances of redis to server, as well as redisNodeFlags to clusterNodeFlags.

---------

Signed-off-by: 0del <bany.y0599@gmail.com>
This commit is contained in:
0del 2024-04-04 08:45:23 +07:00 committed by GitHub
parent 9a02b775c1
commit e3e1f9a372
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 50 additions and 50 deletions

View File

@ -98,7 +98,7 @@ long long serverPopcount(void *s, long count) {
* no zero bit is found, it returns count*8 assuming the string is zero
* padded on the right. However if 'bit' is 1 it is possible that there is
* not a single set bit in the bitmap. In this special case -1 is returned. */
long long redisBitpos(void *s, unsigned long count, int bit) {
long long serverBitpos(void *s, unsigned long count, int bit) {
unsigned long *l;
unsigned char *c;
unsigned long skipval, word = 0, one;
@ -181,7 +181,7 @@ long long redisBitpos(void *s, unsigned long count, int bit) {
/* If we reached this point, there is a bug in the algorithm, since
* the case of no match is handled as a special case before. */
serverPanic("End of redisBitpos() reached.");
serverPanic("End of serverBitpos() reached.");
return 0; /* Just to avoid warnings. */
}
@ -989,7 +989,7 @@ void bitposCommand(client *c) {
if (bit) tmpchar = tmpchar & ~last_byte_neg_mask;
else tmpchar = tmpchar | last_byte_neg_mask;
}
pos = redisBitpos(&tmpchar,1,bit);
pos = serverBitpos(&tmpchar,1,bit);
/* If there are no more bytes or we get valid pos, we can exit early */
if (bytes == 1 || (pos != -1 && pos != 8)) goto result;
start++;
@ -998,7 +998,7 @@ void bitposCommand(client *c) {
/* If the last byte has not bits in the range, we should exclude it */
long curbytes = bytes - (last_byte_neg_mask ? 1 : 0);
if (curbytes > 0) {
pos = redisBitpos(p+start,curbytes,bit);
pos = serverBitpos(p+start,curbytes,bit);
/* If there is no more bytes or we get valid pos, we can exit early */
if (bytes == curbytes || (pos != -1 && pos != (long long)curbytes<<3)) goto result;
start += curbytes;
@ -1006,14 +1006,14 @@ void bitposCommand(client *c) {
}
if (bit) tmpchar = p[end] & ~last_byte_neg_mask;
else tmpchar = p[end] | last_byte_neg_mask;
pos = redisBitpos(&tmpchar,1,bit);
pos = serverBitpos(&tmpchar,1,bit);
result:
/* If we are looking for clear bits, and the user specified an exact
* range with start-end, we can't consider the right of the range as
* zero padded (as we do when no explicit end is given).
*
* So if redisBitpos() returns the first bit outside the range,
* So if serverBitpos() returns the first bit outside the range,
* we return -1 to the caller, to mean, in the specified range there
* is not a single "0" bit. */
if (end_given && bit == 0 && pos == (long long)bytes<<3) {

View File

@ -41,6 +41,6 @@ struct commandDocs {
char *params; /* A string describing the syntax of the command arguments. */
};
extern struct commandDocs redisCommandTable[];
extern struct commandDocs serverCommandTable[];
#endif

View File

@ -5242,12 +5242,12 @@ void clusterSetMaster(clusterNode *n) {
* Nodes to string representation functions.
* -------------------------------------------------------------------------- */
struct redisNodeFlags {
struct clusterNodeFlags {
uint16_t flag;
char *name;
};
static struct redisNodeFlags redisNodeFlagsTable[] = {
static struct clusterNodeFlags clusterNodeFlagsTable[] = {
{CLUSTER_NODE_MYSELF, "myself,"},
{CLUSTER_NODE_MASTER, "master,"},
{CLUSTER_NODE_SLAVE, "slave,"},
@ -5262,9 +5262,9 @@ static struct redisNodeFlags redisNodeFlagsTable[] = {
* string 'ci'. */
sds representClusterNodeFlags(sds ci, uint16_t flags) {
size_t orig_len = sdslen(ci);
int i, size = sizeof(redisNodeFlagsTable)/sizeof(struct redisNodeFlags);
int i, size = sizeof(clusterNodeFlagsTable)/sizeof(struct clusterNodeFlags);
for (i = 0; i < size; i++) {
struct redisNodeFlags *nodeflag = redisNodeFlagsTable + i;
struct clusterNodeFlags *nodeflag = clusterNodeFlagsTable + i;
if (flags & nodeflag->flag) ci = sdscat(ci, nodeflag->name);
}
/* If no flag was added, add the "noflags" special flag. */

View File

@ -10653,7 +10653,7 @@ struct COMMAND_ARG WATCH_Args[] = {
};
/* Main command table */
struct COMMAND_STRUCT redisCommandTable[] = {
struct COMMAND_STRUCT serverCommandTable[] = {
/* bitmap */
{MAKE_CMD("bitcount","Counts the number of set bits (population counting) in a string.","O(N)","2.6.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITCOUNT_History,1,BITCOUNT_Tips,0,bitcountCommand,-2,CMD_READONLY,ACL_CATEGORY_BITMAP,BITCOUNT_Keyspecs,1,NULL,2),.args=BITCOUNT_Args},
{MAKE_CMD("bitfield","Performs arbitrary bitfield integer operations on strings.","O(1) for each subcommand specified","3.2.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITFIELD_History,0,BITFIELD_Tips,0,bitfieldCommand,-2,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_BITMAP,BITFIELD_Keyspecs,1,bitfieldGetKeys,2),.args=BITFIELD_Args},

View File

@ -68,12 +68,12 @@
static uint32_t x[3] = { X0, X1, X2 }, a[3] = { A0, A1, A2 }, c = C;
static void next(void);
int32_t redisLrand48(void) {
int32_t serverLrand48(void) {
next();
return (((int32_t)x[2] << (N - 1)) + (x[1] >> 1));
}
void redisSrand48(int32_t seedval) {
void serverSrand48(int32_t seedval) {
SEED(X0, LOW(seedval), HIGH(seedval));
}

View File

@ -30,8 +30,8 @@
#ifndef VALKEY_RANDOM_H
#define VALKEY_RANDOM_H
int32_t redisLrand48(void);
void redisSrand48(int32_t seedval);
int32_t serverLrand48(void);
void serverSrand48(int32_t seedval);
#define REDIS_LRAND48_MAX INT32_MAX

View File

@ -1542,11 +1542,11 @@ static void luaCreateArray(lua_State *lua, robj **elev, int elec) {
* (for the same seed) in every arch. */
/* The following implementation is the one shipped with Lua itself but with
* rand() replaced by redisLrand48(). */
* rand() replaced by serverLrand48(). */
static int redis_math_random (lua_State *L) {
/* the `%' avoids the (rare) case of r==1, and is needed also because on
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
lua_Number r = (lua_Number)(redisLrand48()%REDIS_LRAND48_MAX) /
lua_Number r = (lua_Number)(serverLrand48()%REDIS_LRAND48_MAX) /
(lua_Number)REDIS_LRAND48_MAX;
switch (lua_gettop(L)) { /* check number of arguments */
case 0: { /* no arguments */
@ -1572,7 +1572,7 @@ static int redis_math_random (lua_State *L) {
}
static int redis_math_randomseed (lua_State *L) {
redisSrand48(luaL_checkint(L, 1));
serverSrand48(luaL_checkint(L, 1));
return 0;
}

View File

@ -3060,7 +3060,7 @@ int populateCommandStructure(struct serverCommand *c) {
return C_OK;
}
extern struct serverCommand redisCommandTable[];
extern struct serverCommand serverCommandTable[];
/* Populates the Redis Command Table dict from the static table in commands.c
* which is auto generated from the json files in the commands folder. */
@ -3069,7 +3069,7 @@ void populateCommandTable(void) {
struct serverCommand *c;
for (j = 0;; j++) {
c = redisCommandTable + j;
c = serverCommandTable + j;
if (c->declared_name == NULL)
break;
@ -6297,7 +6297,7 @@ void usage(void) {
exit(1);
}
void redisAsciiArt(void) {
void serverAsciiArt(void) {
#include "asciilogo.h"
char *buf = zmalloc(1024*16);
char *mode;
@ -6695,7 +6695,7 @@ void loadDataFromDisk(void) {
}
}
void redisOutOfMemoryHandler(size_t allocation_size) {
void serverOutOfMemoryHandler(size_t allocation_size) {
serverLog(LL_WARNING,"Out Of Memory allocating %zu bytes!",
allocation_size);
serverPanic("Redis aborting for OUT OF MEMORY. Allocating %zu bytes!",
@ -6705,7 +6705,7 @@ void redisOutOfMemoryHandler(size_t allocation_size) {
/* Callback for sdstemplate on proc-title-template. See valkey.conf for
* supported variables.
*/
static sds redisProcTitleGetVariable(const sds varname, void *arg)
static sds serverProcTitleGetVariable(const sds varname, void *arg)
{
if (!strcmp(varname, "title")) {
return sdsnew(arg);
@ -6735,7 +6735,7 @@ static sds redisProcTitleGetVariable(const sds varname, void *arg)
/* Expand the specified proc-title-template string and return a newly
* allocated sds, or NULL. */
static sds expandProcTitleTemplate(const char *template, const char *title) {
sds res = sdstemplate(template, redisProcTitleGetVariable, (void *) title);
sds res = sdstemplate(template, serverProcTitleGetVariable, (void *) title);
if (!res)
return NULL;
return sdstrim(res, " ");
@ -6792,7 +6792,7 @@ int serverCommunicateSystemd(const char *sd_notify_msg) {
}
/* Attempt to set up upstart supervision. Returns 1 if successful. */
static int redisSupervisedUpstart(void) {
static int serverSupervisedUpstart(void) {
const char *upstart_job = getenv("UPSTART_JOB");
if (!upstart_job) {
@ -6808,7 +6808,7 @@ static int redisSupervisedUpstart(void) {
}
/* Attempt to set up systemd supervision. Returns 1 if successful. */
static int redisSupervisedSystemd(void) {
static int serverSupervisedSystemd(void) {
#ifndef HAVE_LIBSYSTEMD
serverLog(LL_WARNING,
"systemd supervision requested or auto-detected, but Redis is compiled without libsystemd support!");
@ -6837,10 +6837,10 @@ int redisIsSupervised(int mode) {
switch (mode) {
case SUPERVISED_UPSTART:
ret = redisSupervisedUpstart();
ret = serverSupervisedUpstart();
break;
case SUPERVISED_SYSTEMD:
ret = redisSupervisedSystemd();
ret = serverSupervisedSystemd();
break;
default:
break;
@ -6867,12 +6867,12 @@ int __test_num = 0;
/* The flags are the following:
* --accurate: Runs tests with more iterations.
* --large-memory: Enables tests that consume more than 100mb. */
typedef int redisTestProc(int argc, char **argv, int flags);
struct redisTest {
typedef int serverTestProc(int argc, char **argv, int flags);
struct serverTest {
char *name;
redisTestProc *proc;
serverTestProc *proc;
int failed;
} redisTests[] = {
} serverTests[] = {
{"ziplist", ziplistTest},
{"quicklist", quicklistTest},
{"intset", intsetTest},
@ -6887,11 +6887,11 @@ struct redisTest {
{"listpack", listpackTest},
{"kvstore", kvstoreTest},
};
redisTestProc *getTestProcByName(const char *name) {
int numtests = sizeof(redisTests)/sizeof(struct redisTest);
serverTestProc *getTestProcByName(const char *name) {
int numtests = sizeof(serverTests)/sizeof(struct serverTest);
for (int j = 0; j < numtests; j++) {
if (!strcasecmp(name,redisTests[j].name)) {
return redisTests[j].proc;
if (!strcasecmp(name,serverTests[j].name)) {
return serverTests[j].proc;
}
}
return NULL;
@ -6915,19 +6915,19 @@ int main(int argc, char **argv) {
}
if (!strcasecmp(argv[2], "all")) {
int numtests = sizeof(redisTests)/sizeof(struct redisTest);
int numtests = sizeof(serverTest)/sizeof(struct redisTest);
for (j = 0; j < numtests; j++) {
redisTests[j].failed = (redisTests[j].proc(argc,argv,flags) != 0);
serverTests[j].failed = (serverTests[j].proc(argc,argv,flags) != 0);
}
/* Report tests result */
int failed_num = 0;
for (j = 0; j < numtests; j++) {
if (redisTests[j].failed) {
if (serverTests[j].failed) {
failed_num++;
printf("[failed] Test - %s\n", redisTests[j].name);
printf("[failed] Test - %s\n", serverTests[j].name);
} else {
printf("[ok] Test - %s\n", redisTests[j].name);
printf("[ok] Test - %s\n", serverTests[j].name);
}
}
@ -6936,7 +6936,7 @@ int main(int argc, char **argv) {
return failed_num == 0 ? 0 : 1;
} else {
redisTestProc *proc = getTestProcByName(argv[2]);
serverTestProc *proc = getTestProcByName(argv[2]);
if (!proc) return -1; /* test not found */
return proc(argc,argv,flags);
}
@ -6950,7 +6950,7 @@ int main(int argc, char **argv) {
spt_init(argc, argv);
#endif
tzset(); /* Populates 'timezone' global. */
zmalloc_set_oom_handler(redisOutOfMemoryHandler);
zmalloc_set_oom_handler(serverOutOfMemoryHandler);
/* To achieve entropy, in case of containers, their time() and getpid() can
* be the same. But value of tv_usec is fast enough to make the difference */
@ -7171,7 +7171,7 @@ int main(int argc, char **argv) {
initServer();
if (background || server.pidfile) createPidFile();
if (server.set_proc_title) serverSetProcTitle(NULL);
redisAsciiArt();
serverAsciiArt();
checkTcpBacklogSettings();
if (server.cluster_enabled) {
clusterInit();

View File

@ -3781,9 +3781,9 @@ sds getVersion(void);
_serverLog(level, __VA_ARGS__);\
} while(0)
#define redisDebug(fmt, ...) \
#define serverDebug(fmt, ...) \
printf("DEBUG %s:%d > " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)
#define redisDebugMark() \
#define serverDebugMark() \
printf("-- MARK %s:%d --\n", __FILE__, __LINE__)
int iAmMaster(void);

View File

@ -878,10 +878,10 @@ static void cliLegacyInitHelp(dict *groups) {
sds serverVersion = cliGetServerVersion();
/* Scan the commandDocs array and fill in the entries */
helpEntriesLen = cliLegacyCountCommands(redisCommandTable, serverVersion);
helpEntriesLen = cliLegacyCountCommands(serverCommandTable, serverVersion);
helpEntries = zmalloc(sizeof(helpEntry)*helpEntriesLen);
helpEntriesLen = cliLegacyInitCommandHelpEntries(redisCommandTable, groups, serverVersion);
helpEntriesLen = cliLegacyInitCommandHelpEntries(serverCommandTable, groups, serverVersion);
cliInitGroupHelpEntries(groups);
qsort(helpEntries, helpEntriesLen, sizeof(helpEntry), helpEntryCompare);

View File

@ -611,7 +611,7 @@ const char *commandGroupStr(int index) {
command.write_internal_structs(f)
f.write("/* Main command table */\n")
f.write("struct COMMAND_STRUCT redisCommandTable[] = {\n")
f.write("struct COMMAND_STRUCT serverCommandTable[] = {\n")
curr_group = None
for command in command_list:
if curr_group != command.group: