Factor out some normally const globals
Former-commit-id: fa2e407873fce7f936943ae1fe162d54d7bedd70
This commit is contained in:
parent
9a4dbf33e7
commit
e2e3acf04c
@ -46,10 +46,8 @@
|
||||
|
||||
#include "ae.h"
|
||||
#include "fastlock.h"
|
||||
extern "C" {
|
||||
#include "zmalloc.h"
|
||||
#include "config.h"
|
||||
}
|
||||
|
||||
#ifdef USE_MUTEX
|
||||
thread_local int cOwnLock = 0;
|
||||
@ -209,7 +207,7 @@ int aeCreateRemoteFileEvent(aeEventLoop *eventLoop, int fd, int mask,
|
||||
cmd.clientData = clientData;
|
||||
cmd.pctl = nullptr;
|
||||
if (fSynchronous)
|
||||
cmd.pctl = new aeCommandControl();
|
||||
cmd.pctl = new (MALLOC_LOCAL) aeCommandControl();
|
||||
|
||||
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv, std::defer_lock);
|
||||
if (fSynchronous)
|
||||
@ -257,10 +255,10 @@ int aePostFunction(aeEventLoop *eventLoop, std::function<void()> fn, bool fSynch
|
||||
|
||||
aeCommand cmd;
|
||||
cmd.op = AE_ASYNC_OP::PostCppFunction;
|
||||
cmd.pfn = new std::function<void()>(fn);
|
||||
cmd.pfn = new (MALLOC_LOCAL) std::function<void()>(fn);
|
||||
cmd.pctl = nullptr;
|
||||
if (fSynchronous)
|
||||
cmd.pctl = new aeCommandControl();
|
||||
cmd.pctl = new (MALLOC_LOCAL) aeCommandControl();
|
||||
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv, std::defer_lock);
|
||||
if (fSynchronous)
|
||||
cmd.pctl->mutexcv.lock();
|
||||
|
@ -594,10 +594,10 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
|
||||
}
|
||||
serverAssert(!(exarg && pxarg));
|
||||
if (exarg)
|
||||
buf = catAppendOnlyExpireAtCommand(buf,server.expireCommand,argv[1],
|
||||
buf = catAppendOnlyExpireAtCommand(buf,cserver.expireCommand,argv[1],
|
||||
exarg);
|
||||
if (pxarg)
|
||||
buf = catAppendOnlyExpireAtCommand(buf,server.pexpireCommand,argv[1],
|
||||
buf = catAppendOnlyExpireAtCommand(buf,cserver.pexpireCommand,argv[1],
|
||||
pxarg);
|
||||
} else {
|
||||
/* All the other commands don't need translation or need the
|
||||
@ -798,7 +798,7 @@ int loadAppendOnlyFile(char *filename) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (cmd == server.multiCommand) valid_before_multi = valid_up_to;
|
||||
if (cmd == cserver.multiCommand) valid_before_multi = valid_up_to;
|
||||
|
||||
/* Run the command in the context of a fake client */
|
||||
fakeClient->cmd = cmd;
|
||||
@ -1279,7 +1279,7 @@ int rewriteAppendOnlyFileRio(rio *aof) {
|
||||
size_t processed = 0;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < server.dbnum; j++) {
|
||||
for (j = 0; j < cserver.dbnum; j++) {
|
||||
char selectcmd[] = "*2\r\n$6\r\nSELECT\r\n";
|
||||
redisDb *db = server.db+j;
|
||||
dict *d = db->pdict;
|
||||
|
@ -385,8 +385,8 @@ void handleClientsBlockedOnKeys(void) {
|
||||
/* Replicate the command. */
|
||||
robj *argv[2];
|
||||
struct redisCommand *cmd = where == ZSET_MIN ?
|
||||
server.zpopminCommand :
|
||||
server.zpopmaxCommand;
|
||||
cserver.zpopminCommand :
|
||||
cserver.zpopmaxCommand;
|
||||
argv[0] = createStringObject(cmd->name,strlen(cmd->name));
|
||||
argv[1] = rl->key;
|
||||
incrRefCount(rl->key);
|
||||
|
@ -1362,7 +1362,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
|
||||
clusterNode *node;
|
||||
sds ci;
|
||||
|
||||
if (server.verbosity == LL_DEBUG) {
|
||||
if (cserver.verbosity == LL_DEBUG) {
|
||||
ci = representClusterNodeFlags(sdsempty(), flags);
|
||||
serverLog(LL_DEBUG,"GOSSIP %.40s %s:%d@%d %s",
|
||||
g->nodename,
|
||||
@ -3909,7 +3909,7 @@ int verifyClusterConfigWithData(void) {
|
||||
if (nodeIsSlave(myself)) return C_OK;
|
||||
|
||||
/* Make sure we only have keys in DB0. */
|
||||
for (j = 1; j < server.dbnum; j++) {
|
||||
for (j = 1; j < cserver.dbnum; j++) {
|
||||
if (dictSize(server.db[j].pdict)) return C_ERR;
|
||||
}
|
||||
|
||||
|
216
src/config.cpp
216
src/config.cpp
@ -205,13 +205,13 @@ void loadServerConfigFromString(char *config) {
|
||||
|
||||
/* Execute config directives */
|
||||
if (!strcasecmp(argv[0],"timeout") && argc == 2) {
|
||||
server.maxidletime = atoi(argv[1]);
|
||||
if (server.maxidletime < 0) {
|
||||
cserver.maxidletime = atoi(argv[1]);
|
||||
if (cserver.maxidletime < 0) {
|
||||
err = "Invalid timeout value"; goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"tcp-keepalive") && argc == 2) {
|
||||
server.tcpkeepalive = atoi(argv[1]);
|
||||
if (server.tcpkeepalive < 0) {
|
||||
cserver.tcpkeepalive = atoi(argv[1]);
|
||||
if (cserver.tcpkeepalive < 0) {
|
||||
err = "Invalid tcp-keepalive value"; goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"protected-mode") && argc == 2) {
|
||||
@ -263,8 +263,8 @@ void loadServerConfigFromString(char *config) {
|
||||
exit(1);
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"loglevel") && argc == 2) {
|
||||
server.verbosity = configEnumGetValue(loglevel_enum,argv[1]);
|
||||
if (server.verbosity == INT_MIN) {
|
||||
cserver.verbosity = configEnumGetValue(loglevel_enum,argv[1]);
|
||||
if (cserver.verbosity == INT_MIN) {
|
||||
err = "Invalid log level. "
|
||||
"Must be one of debug, verbose, notice, warning";
|
||||
goto loaderr;
|
||||
@ -307,8 +307,8 @@ void loadServerConfigFromString(char *config) {
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"databases") && argc == 2) {
|
||||
server.dbnum = atoi(argv[1]);
|
||||
if (server.dbnum < 1) {
|
||||
cserver.dbnum = atoi(argv[1]);
|
||||
if (cserver.dbnum < 1) {
|
||||
err = "Invalid number of databases"; goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"include") && argc == 2) {
|
||||
@ -336,7 +336,7 @@ void loadServerConfigFromString(char *config) {
|
||||
} else if ((!strcasecmp(argv[0],"proto-max-bulk-len")) && argc == 2) {
|
||||
server.proto_max_bulk_len = memtoll(argv[1],NULL);
|
||||
} else if ((!strcasecmp(argv[0],"client-query-buffer-limit")) && argc == 2) {
|
||||
server.client_max_querybuf_len = memtoll(argv[1],NULL);
|
||||
cserver.client_max_querybuf_len = memtoll(argv[1],NULL);
|
||||
} else if (!strcasecmp(argv[0],"lfu-log-factor") && argc == 2) {
|
||||
server.lfu_log_factor = atoi(argv[1]);
|
||||
if (server.lfu_log_factor < 0) {
|
||||
@ -396,11 +396,11 @@ void loadServerConfigFromString(char *config) {
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"masteruser") && argc == 2) {
|
||||
zfree(server.default_masteruser);
|
||||
server.default_masteruser = argv[1][0] ? zstrdup(argv[1]) : NULL;
|
||||
zfree(cserver.default_masteruser);
|
||||
cserver.default_masteruser = argv[1][0] ? zstrdup(argv[1]) : NULL;
|
||||
} else if (!strcasecmp(argv[0],"masterauth") && argc == 2) {
|
||||
zfree(server.default_masterauth);
|
||||
server.default_masterauth = argv[1][0] ? zstrdup(argv[1]) : NULL;
|
||||
zfree(cserver.default_masterauth);
|
||||
cserver.default_masterauth = argv[1][0] ? zstrdup(argv[1]) : NULL;
|
||||
// Loop through all existing master infos and update them (in case this came after the replicaof config)
|
||||
updateMasterAuth();
|
||||
} else if ((!strcasecmp(argv[0],"slave-serve-stale-data") ||
|
||||
@ -455,16 +455,16 @@ void loadServerConfigFromString(char *config) {
|
||||
err = "argument must be 'yes' or 'no'"; goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"activedefrag") && argc == 2) {
|
||||
if ((server.active_defrag_enabled = yesnotoi(argv[1])) == -1) {
|
||||
if ((cserver.active_defrag_enabled = yesnotoi(argv[1])) == -1) {
|
||||
err = "argument must be 'yes' or 'no'"; goto loaderr;
|
||||
}
|
||||
if (server.active_defrag_enabled) {
|
||||
if (cserver.active_defrag_enabled) {
|
||||
#ifndef HAVE_DEFRAG
|
||||
err = "active defrag can't be enabled without proper jemalloc support"; goto loaderr;
|
||||
#endif
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"daemonize") && argc == 2) {
|
||||
if ((server.daemonize = yesnotoi(argv[1])) == -1) {
|
||||
if ((cserver.daemonize = yesnotoi(argv[1])) == -1) {
|
||||
err = "argument must be 'yes' or 'no'"; goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"dynamic-hz") && argc == 2) {
|
||||
@ -546,8 +546,8 @@ void loadServerConfigFromString(char *config) {
|
||||
ACLSetUser(DefaultUser,aclop,sdslen(aclop));
|
||||
sdsfree(aclop);
|
||||
} else if (!strcasecmp(argv[0],"pidfile") && argc == 2) {
|
||||
zfree(server.pidfile);
|
||||
server.pidfile = zstrdup(argv[1]);
|
||||
zfree(cserver.pidfile);
|
||||
cserver.pidfile = zstrdup(argv[1]);
|
||||
} else if (!strcasecmp(argv[0],"dbfilename") && argc == 2) {
|
||||
if (!pathIsBaseName(argv[1])) {
|
||||
err = "dbfilename can't be a path, just a filename";
|
||||
@ -559,40 +559,40 @@ void loadServerConfigFromString(char *config) {
|
||||
zfree(server.rdb_s3bucketpath);
|
||||
server.rdb_s3bucketpath = zstrdup(argv[1]);
|
||||
} else if (!strcasecmp(argv[0],"active-defrag-threshold-lower") && argc == 2) {
|
||||
server.active_defrag_threshold_lower = atoi(argv[1]);
|
||||
if (server.active_defrag_threshold_lower < 0 ||
|
||||
server.active_defrag_threshold_lower > 1000) {
|
||||
cserver.active_defrag_threshold_lower = atoi(argv[1]);
|
||||
if (cserver.active_defrag_threshold_lower < 0 ||
|
||||
cserver.active_defrag_threshold_lower > 1000) {
|
||||
err = "active-defrag-threshold-lower must be between 0 and 1000";
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"active-defrag-threshold-upper") && argc == 2) {
|
||||
server.active_defrag_threshold_upper = atoi(argv[1]);
|
||||
if (server.active_defrag_threshold_upper < 0 ||
|
||||
server.active_defrag_threshold_upper > 1000) {
|
||||
cserver.active_defrag_threshold_upper = atoi(argv[1]);
|
||||
if (cserver.active_defrag_threshold_upper < 0 ||
|
||||
cserver.active_defrag_threshold_upper > 1000) {
|
||||
err = "active-defrag-threshold-upper must be between 0 and 1000";
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"active-defrag-ignore-bytes") && argc == 2) {
|
||||
server.active_defrag_ignore_bytes = memtoll(argv[1], NULL);
|
||||
if (server.active_defrag_ignore_bytes <= 0) {
|
||||
cserver.active_defrag_ignore_bytes = memtoll(argv[1], NULL);
|
||||
if (cserver.active_defrag_ignore_bytes <= 0) {
|
||||
err = "active-defrag-ignore-bytes must above 0";
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"active-defrag-cycle-min") && argc == 2) {
|
||||
server.active_defrag_cycle_min = atoi(argv[1]);
|
||||
if (server.active_defrag_cycle_min < 1 || server.active_defrag_cycle_min > 99) {
|
||||
cserver.active_defrag_cycle_min = atoi(argv[1]);
|
||||
if (cserver.active_defrag_cycle_min < 1 || cserver.active_defrag_cycle_min > 99) {
|
||||
err = "active-defrag-cycle-min must be between 1 and 99";
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"active-defrag-cycle-max") && argc == 2) {
|
||||
server.active_defrag_cycle_max = atoi(argv[1]);
|
||||
if (server.active_defrag_cycle_max < 1 || server.active_defrag_cycle_max > 99) {
|
||||
cserver.active_defrag_cycle_max = atoi(argv[1]);
|
||||
if (cserver.active_defrag_cycle_max < 1 || cserver.active_defrag_cycle_max > 99) {
|
||||
err = "active-defrag-cycle-max must be between 1 and 99";
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"active-defrag-max-scan-fields") && argc == 2) {
|
||||
server.active_defrag_max_scan_fields = strtoll(argv[1],NULL,10);
|
||||
if (server.active_defrag_max_scan_fields < 1) {
|
||||
cserver.active_defrag_max_scan_fields = strtoll(argv[1],NULL,10);
|
||||
if (cserver.active_defrag_max_scan_fields < 1) {
|
||||
err = "active-defrag-max-scan-fields must be positive";
|
||||
goto loaderr;
|
||||
}
|
||||
@ -745,9 +745,9 @@ void loadServerConfigFromString(char *config) {
|
||||
err = "Negative number of seconds in soft limit is invalid";
|
||||
goto loaderr;
|
||||
}
|
||||
server.client_obuf_limits[type].hard_limit_bytes = hard;
|
||||
server.client_obuf_limits[type].soft_limit_bytes = soft;
|
||||
server.client_obuf_limits[type].soft_limit_seconds = soft_seconds;
|
||||
cserver.client_obuf_limits[type].hard_limit_bytes = hard;
|
||||
cserver.client_obuf_limits[type].soft_limit_bytes = soft;
|
||||
cserver.client_obuf_limits[type].soft_limit_seconds = soft_seconds;
|
||||
} else if (!strcasecmp(argv[0],"stop-writes-on-bgsave-error") &&
|
||||
argc == 2) {
|
||||
if ((server.stop_writes_on_bgsave_err = yesnotoi(argv[1])) == -1) {
|
||||
@ -794,10 +794,10 @@ void loadServerConfigFromString(char *config) {
|
||||
}
|
||||
server.notify_keyspace_events = flags;
|
||||
} else if (!strcasecmp(argv[0],"supervised") && argc == 2) {
|
||||
server.supervised_mode =
|
||||
cserver.supervised_mode =
|
||||
configEnumGetValue(supervised_mode_enum,argv[1]);
|
||||
|
||||
if (server.supervised_mode == INT_MIN) {
|
||||
if (cserver.supervised_mode == INT_MIN) {
|
||||
err = "Invalid option for 'supervised'. "
|
||||
"Allowed values: 'upstart', 'systemd', 'auto', or 'no'";
|
||||
goto loaderr;
|
||||
@ -833,16 +833,16 @@ void loadServerConfigFromString(char *config) {
|
||||
goto loaderr;
|
||||
#endif
|
||||
} else if (!strcasecmp(argv[0],"server-threads") && argc == 2) {
|
||||
server.cthreads = atoi(argv[1]);
|
||||
if (server.cthreads <= 0 || server.cthreads > MAX_EVENT_LOOPS) {
|
||||
cserver.cthreads = atoi(argv[1]);
|
||||
if (cserver.cthreads <= 0 || cserver.cthreads > MAX_EVENT_LOOPS) {
|
||||
err = "Invalid number of threads specified";
|
||||
goto loaderr;
|
||||
}
|
||||
} else if (!strcasecmp(argv[0],"server-thread-affinity") && argc == 2) {
|
||||
if (strcasecmp(argv[1], "true") == 0) {
|
||||
server.fThreadAffinity = TRUE;
|
||||
cserver.fThreadAffinity = TRUE;
|
||||
} else if (strcasecmp(argv[1], "false") == 0) {
|
||||
server.fThreadAffinity = FALSE;
|
||||
cserver.fThreadAffinity = FALSE;
|
||||
} else {
|
||||
err = "Unknown argument: server-thread-affinity expects either true or false";
|
||||
goto loaderr;
|
||||
@ -991,11 +991,11 @@ void configSetCommand(client *c) {
|
||||
ACLSetUser(DefaultUser,aclop,sdslen(aclop));
|
||||
sdsfree(aclop);
|
||||
} config_set_special_field("masteruser") {
|
||||
zfree(server.default_masteruser);
|
||||
server.default_masteruser = ((char*)ptrFromObj(o))[0] ? zstrdup(szFromObj(o)) : NULL;
|
||||
zfree(cserver.default_masteruser);
|
||||
cserver.default_masteruser = ((char*)ptrFromObj(o))[0] ? zstrdup(szFromObj(o)) : NULL;
|
||||
} config_set_special_field("masterauth") {
|
||||
zfree(server.default_masterauth);
|
||||
server.default_masterauth = ((char*)ptrFromObj(o))[0] ? zstrdup(szFromObj(o)) : NULL;
|
||||
zfree(cserver.default_masterauth);
|
||||
cserver.default_masterauth = ((char*)ptrFromObj(o))[0] ? zstrdup(szFromObj(o)) : NULL;
|
||||
} config_set_special_field("cluster-announce-ip") {
|
||||
zfree(server.cluster_announce_ip);
|
||||
server.cluster_announce_ip = ((char*)ptrFromObj(o))[0] ? zstrdup(szFromObj(o)) : NULL;
|
||||
@ -1017,7 +1017,7 @@ void configSetCommand(client *c) {
|
||||
if ((unsigned int) aeGetSetSize(server.rgthreadvar[IDX_EVENT_LOOP_MAIN].el) <
|
||||
server.maxclients + CONFIG_FDSET_INCR)
|
||||
{
|
||||
for (int iel = 0; iel < server.cthreads; ++iel)
|
||||
for (int iel = 0; iel < cserver.cthreads; ++iel)
|
||||
{
|
||||
if (aeResizeSetSize(server.rgthreadvar[iel].el,
|
||||
server.maxclients + CONFIG_FDSET_INCR) == AE_ERR)
|
||||
@ -1121,9 +1121,9 @@ void configSetCommand(client *c) {
|
||||
soft = memtoll(v[j+2],NULL);
|
||||
soft_seconds = strtoll(v[j+3],NULL,10);
|
||||
|
||||
server.client_obuf_limits[type].hard_limit_bytes = hard;
|
||||
server.client_obuf_limits[type].soft_limit_bytes = soft;
|
||||
server.client_obuf_limits[type].soft_limit_seconds = soft_seconds;
|
||||
cserver.client_obuf_limits[type].hard_limit_bytes = hard;
|
||||
cserver.client_obuf_limits[type].soft_limit_bytes = soft;
|
||||
cserver.client_obuf_limits[type].soft_limit_seconds = soft_seconds;
|
||||
}
|
||||
sdsfreesplitres(v,vlen);
|
||||
} config_set_special_field("notify-keyspace-events") {
|
||||
@ -1174,10 +1174,10 @@ void configSetCommand(client *c) {
|
||||
} config_set_bool_field(
|
||||
"activerehashing",server.activerehashing) {
|
||||
} config_set_bool_field(
|
||||
"activedefrag",server.active_defrag_enabled) {
|
||||
"activedefrag",cserver.active_defrag_enabled) {
|
||||
#ifndef HAVE_DEFRAG
|
||||
if (server.active_defrag_enabled) {
|
||||
server.active_defrag_enabled = 0;
|
||||
if (cserver.active_defrag_enabled) {
|
||||
cserver.active_defrag_enabled = 0;
|
||||
addReplyError(c,
|
||||
"-DISABLED Active defragmentation cannot be enabled: it "
|
||||
"requires a Redis server compiled with a modified Jemalloc "
|
||||
@ -1208,7 +1208,7 @@ void configSetCommand(client *c) {
|
||||
/* Numerical fields.
|
||||
* config_set_numerical_field(name,var,min,max) */
|
||||
} config_set_numerical_field(
|
||||
"tcp-keepalive",server.tcpkeepalive,0,INT_MAX) {
|
||||
"tcp-keepalive",cserver.tcpkeepalive,0,INT_MAX) {
|
||||
} config_set_numerical_field(
|
||||
"maxmemory-samples",server.maxmemory_samples,1,INT_MAX) {
|
||||
} config_set_numerical_field(
|
||||
@ -1216,19 +1216,19 @@ void configSetCommand(client *c) {
|
||||
} config_set_numerical_field(
|
||||
"lfu-decay-time",server.lfu_decay_time,0,INT_MAX) {
|
||||
} config_set_numerical_field(
|
||||
"timeout",server.maxidletime,0,INT_MAX) {
|
||||
"timeout",cserver.maxidletime,0,INT_MAX) {
|
||||
} config_set_numerical_field(
|
||||
"active-defrag-threshold-lower",server.active_defrag_threshold_lower,0,1000) {
|
||||
"active-defrag-threshold-lower",cserver.active_defrag_threshold_lower,0,1000) {
|
||||
} config_set_numerical_field(
|
||||
"active-defrag-threshold-upper",server.active_defrag_threshold_upper,0,1000) {
|
||||
"active-defrag-threshold-upper",cserver.active_defrag_threshold_upper,0,1000) {
|
||||
} config_set_memory_field(
|
||||
"active-defrag-ignore-bytes",server.active_defrag_ignore_bytes) {
|
||||
"active-defrag-ignore-bytes",cserver.active_defrag_ignore_bytes) {
|
||||
} config_set_numerical_field(
|
||||
"active-defrag-cycle-min",server.active_defrag_cycle_min,1,99) {
|
||||
"active-defrag-cycle-min",cserver.active_defrag_cycle_min,1,99) {
|
||||
} config_set_numerical_field(
|
||||
"active-defrag-cycle-max",server.active_defrag_cycle_max,1,99) {
|
||||
"active-defrag-cycle-max",cserver.active_defrag_cycle_max,1,99) {
|
||||
} config_set_numerical_field(
|
||||
"active-defrag-max-scan-fields",server.active_defrag_max_scan_fields,1,LONG_MAX) {
|
||||
"active-defrag-max-scan-fields",cserver.active_defrag_max_scan_fields,1,LONG_MAX) {
|
||||
} config_set_numerical_field(
|
||||
"auto-aof-rewrite-percentage",server.aof_rewrite_perc,0,INT_MAX){
|
||||
} config_set_numerical_field(
|
||||
@ -1328,7 +1328,7 @@ void configSetCommand(client *c) {
|
||||
} config_set_memory_field(
|
||||
"proto-max-bulk-len",server.proto_max_bulk_len) {
|
||||
} config_set_memory_field(
|
||||
"client-query-buffer-limit",server.client_max_querybuf_len) {
|
||||
"client-query-buffer-limit",cserver.client_max_querybuf_len) {
|
||||
} config_set_memory_field("repl-backlog-size",ll) {
|
||||
resizeReplicationBacklog(ll);
|
||||
} config_set_memory_field("auto-aof-rewrite-min-size",ll) {
|
||||
@ -1337,7 +1337,7 @@ void configSetCommand(client *c) {
|
||||
/* Enumeration fields.
|
||||
* config_set_enum_field(name,var,enum_var) */
|
||||
} config_set_enum_field(
|
||||
"loglevel",server.verbosity,loglevel_enum) {
|
||||
"loglevel",cserver.verbosity,loglevel_enum) {
|
||||
} config_set_enum_field(
|
||||
"maxmemory-policy",server.maxmemory_policy,maxmemory_policy_enum) {
|
||||
} config_set_bool_field(
|
||||
@ -1409,13 +1409,13 @@ void configGetCommand(client *c) {
|
||||
|
||||
/* String values */
|
||||
config_get_string_field("dbfilename",server.rdb_filename);
|
||||
config_get_string_field("masteruser",server.default_masteruser);
|
||||
config_get_string_field("masterauth",server.default_masterauth);
|
||||
config_get_string_field("masteruser",cserver.default_masteruser);
|
||||
config_get_string_field("masterauth",cserver.default_masterauth);
|
||||
config_get_string_field("cluster-announce-ip",server.cluster_announce_ip);
|
||||
config_get_string_field("unixsocket",server.unixsocket);
|
||||
config_get_string_field("logfile",server.logfile);
|
||||
config_get_string_field("aclfile",server.acl_filename);
|
||||
config_get_string_field("pidfile",server.pidfile);
|
||||
config_get_string_field("pidfile",cserver.pidfile);
|
||||
config_get_string_field("slave-announce-ip",server.slave_announce_ip);
|
||||
config_get_string_field("replica-announce-ip",server.slave_announce_ip);
|
||||
config_get_string_field("version-override",KEYDB_SET_VERSION);
|
||||
@ -1423,17 +1423,17 @@ void configGetCommand(client *c) {
|
||||
/* Numerical values */
|
||||
config_get_numerical_field("maxmemory",server.maxmemory);
|
||||
config_get_numerical_field("proto-max-bulk-len",server.proto_max_bulk_len);
|
||||
config_get_numerical_field("client-query-buffer-limit",server.client_max_querybuf_len);
|
||||
config_get_numerical_field("client-query-buffer-limit",cserver.client_max_querybuf_len);
|
||||
config_get_numerical_field("maxmemory-samples",server.maxmemory_samples);
|
||||
config_get_numerical_field("lfu-log-factor",server.lfu_log_factor);
|
||||
config_get_numerical_field("lfu-decay-time",server.lfu_decay_time);
|
||||
config_get_numerical_field("timeout",server.maxidletime);
|
||||
config_get_numerical_field("active-defrag-threshold-lower",server.active_defrag_threshold_lower);
|
||||
config_get_numerical_field("active-defrag-threshold-upper",server.active_defrag_threshold_upper);
|
||||
config_get_numerical_field("active-defrag-ignore-bytes",server.active_defrag_ignore_bytes);
|
||||
config_get_numerical_field("active-defrag-cycle-min",server.active_defrag_cycle_min);
|
||||
config_get_numerical_field("active-defrag-cycle-max",server.active_defrag_cycle_max);
|
||||
config_get_numerical_field("active-defrag-max-scan-fields",server.active_defrag_max_scan_fields);
|
||||
config_get_numerical_field("timeout",cserver.maxidletime);
|
||||
config_get_numerical_field("active-defrag-threshold-lower",cserver.active_defrag_threshold_lower);
|
||||
config_get_numerical_field("active-defrag-threshold-upper",cserver.active_defrag_threshold_upper);
|
||||
config_get_numerical_field("active-defrag-ignore-bytes",cserver.active_defrag_ignore_bytes);
|
||||
config_get_numerical_field("active-defrag-cycle-min",cserver.active_defrag_cycle_min);
|
||||
config_get_numerical_field("active-defrag-cycle-max",cserver.active_defrag_cycle_max);
|
||||
config_get_numerical_field("active-defrag-max-scan-fields",cserver.active_defrag_max_scan_fields);
|
||||
config_get_numerical_field("auto-aof-rewrite-percentage",
|
||||
server.aof_rewrite_perc);
|
||||
config_get_numerical_field("auto-aof-rewrite-min-size",
|
||||
@ -1469,7 +1469,7 @@ void configGetCommand(client *c) {
|
||||
config_get_numerical_field("cluster-announce-port",server.cluster_announce_port);
|
||||
config_get_numerical_field("cluster-announce-bus-port",server.cluster_announce_bus_port);
|
||||
config_get_numerical_field("tcp-backlog",server.tcp_backlog);
|
||||
config_get_numerical_field("databases",server.dbnum);
|
||||
config_get_numerical_field("databases",cserver.dbnum);
|
||||
config_get_numerical_field("repl-ping-slave-period",server.repl_ping_slave_period);
|
||||
config_get_numerical_field("repl-ping-replica-period",server.repl_ping_slave_period);
|
||||
config_get_numerical_field("repl-timeout",server.repl_timeout);
|
||||
@ -1491,7 +1491,7 @@ void configGetCommand(client *c) {
|
||||
config_get_numerical_field("cluster-slave-validity-factor",server.cluster_slave_validity_factor);
|
||||
config_get_numerical_field("cluster-replica-validity-factor",server.cluster_slave_validity_factor);
|
||||
config_get_numerical_field("repl-diskless-sync-delay",server.repl_diskless_sync_delay);
|
||||
config_get_numerical_field("tcp-keepalive",server.tcpkeepalive);
|
||||
config_get_numerical_field("tcp-keepalive",cserver.tcpkeepalive);
|
||||
|
||||
/* Bool (yes/no) values */
|
||||
config_get_bool_field("cluster-require-full-coverage",
|
||||
@ -1516,11 +1516,11 @@ void configGetCommand(client *c) {
|
||||
server.repl_slave_ignore_maxmemory);
|
||||
config_get_bool_field("stop-writes-on-bgsave-error",
|
||||
server.stop_writes_on_bgsave_err);
|
||||
config_get_bool_field("daemonize", server.daemonize);
|
||||
config_get_bool_field("daemonize", cserver.daemonize);
|
||||
config_get_bool_field("rdbcompression", server.rdb_compression);
|
||||
config_get_bool_field("rdbchecksum", server.rdb_checksum);
|
||||
config_get_bool_field("activerehashing", server.activerehashing);
|
||||
config_get_bool_field("activedefrag", server.active_defrag_enabled);
|
||||
config_get_bool_field("activedefrag", cserver.active_defrag_enabled);
|
||||
config_get_bool_field("protected-mode", server.protected_mode);
|
||||
config_get_bool_field("repl-disable-tcp-nodelay",
|
||||
server.repl_disable_tcp_nodelay);
|
||||
@ -1551,9 +1551,9 @@ void configGetCommand(client *c) {
|
||||
config_get_enum_field("maxmemory-policy",
|
||||
server.maxmemory_policy,maxmemory_policy_enum);
|
||||
config_get_enum_field("loglevel",
|
||||
server.verbosity,loglevel_enum);
|
||||
cserver.verbosity,loglevel_enum);
|
||||
config_get_enum_field("supervised",
|
||||
server.supervised_mode,supervised_mode_enum);
|
||||
cserver.supervised_mode,supervised_mode_enum);
|
||||
config_get_enum_field("appendfsync",
|
||||
server.aof_fsync,aof_fsync_enum);
|
||||
config_get_enum_field("syslog-facility",
|
||||
@ -1599,9 +1599,9 @@ void configGetCommand(client *c) {
|
||||
for (j = 0; j < CLIENT_TYPE_OBUF_COUNT; j++) {
|
||||
buf = sdscatprintf(buf,"%s %llu %llu %ld",
|
||||
getClientTypeName(j),
|
||||
server.client_obuf_limits[j].hard_limit_bytes,
|
||||
server.client_obuf_limits[j].soft_limit_bytes,
|
||||
(long) server.client_obuf_limits[j].soft_limit_seconds);
|
||||
cserver.client_obuf_limits[j].hard_limit_bytes,
|
||||
cserver.client_obuf_limits[j].soft_limit_bytes,
|
||||
(long) cserver.client_obuf_limits[j].soft_limit_seconds);
|
||||
if (j != CLIENT_TYPE_OBUF_COUNT-1)
|
||||
buf = sdscatlen(buf," ",1);
|
||||
}
|
||||
@ -2076,25 +2076,25 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state
|
||||
const char *option = "client-output-buffer-limit";
|
||||
|
||||
for (j = 0; j < CLIENT_TYPE_OBUF_COUNT; j++) {
|
||||
int force = (server.client_obuf_limits[j].hard_limit_bytes !=
|
||||
int force = (cserver.client_obuf_limits[j].hard_limit_bytes !=
|
||||
clientBufferLimitsDefaults[j].hard_limit_bytes) ||
|
||||
(server.client_obuf_limits[j].soft_limit_bytes !=
|
||||
(cserver.client_obuf_limits[j].soft_limit_bytes !=
|
||||
clientBufferLimitsDefaults[j].soft_limit_bytes) ||
|
||||
(server.client_obuf_limits[j].soft_limit_seconds !=
|
||||
(cserver.client_obuf_limits[j].soft_limit_seconds !=
|
||||
clientBufferLimitsDefaults[j].soft_limit_seconds);
|
||||
sds line;
|
||||
char hard[64], soft[64];
|
||||
|
||||
rewriteConfigFormatMemory(hard,sizeof(hard),
|
||||
server.client_obuf_limits[j].hard_limit_bytes);
|
||||
cserver.client_obuf_limits[j].hard_limit_bytes);
|
||||
rewriteConfigFormatMemory(soft,sizeof(soft),
|
||||
server.client_obuf_limits[j].soft_limit_bytes);
|
||||
cserver.client_obuf_limits[j].soft_limit_bytes);
|
||||
|
||||
const char *tname = getClientTypeName(j);
|
||||
if (!strcmp(tname,"slave")) tname = "replica";
|
||||
line = sdscatprintf(sdsempty(),"%s %s %s %s %ld",
|
||||
option, tname, hard, soft,
|
||||
(long) server.client_obuf_limits[j].soft_limit_seconds);
|
||||
(long) cserver.client_obuf_limits[j].soft_limit_seconds);
|
||||
rewriteConfigRewriteLine(state,option,line,force);
|
||||
}
|
||||
}
|
||||
@ -2280,8 +2280,8 @@ int rewriteConfig(char *path) {
|
||||
/* Step 2: rewrite every single option, replacing or appending it inside
|
||||
* the rewrite state. */
|
||||
|
||||
rewriteConfigYesNoOption(state,"daemonize",server.daemonize,0);
|
||||
rewriteConfigStringOption(state,"pidfile",server.pidfile,CONFIG_DEFAULT_PID_FILE);
|
||||
rewriteConfigYesNoOption(state,"daemonize",cserver.daemonize,0);
|
||||
rewriteConfigStringOption(state,"pidfile",cserver.pidfile,CONFIG_DEFAULT_PID_FILE);
|
||||
rewriteConfigNumericalOption(state,"port",server.port,CONFIG_DEFAULT_SERVER_PORT);
|
||||
rewriteConfigNumericalOption(state,"cluster-announce-port",server.cluster_announce_port,CONFIG_DEFAULT_CLUSTER_ANNOUNCE_PORT);
|
||||
rewriteConfigNumericalOption(state,"cluster-announce-bus-port",server.cluster_announce_bus_port,CONFIG_DEFAULT_CLUSTER_ANNOUNCE_BUS_PORT);
|
||||
@ -2289,10 +2289,10 @@ int rewriteConfig(char *path) {
|
||||
rewriteConfigBindOption(state);
|
||||
rewriteConfigStringOption(state,"unixsocket",server.unixsocket,NULL);
|
||||
rewriteConfigOctalOption(state,"unixsocketperm",server.unixsocketperm,CONFIG_DEFAULT_UNIX_SOCKET_PERM);
|
||||
rewriteConfigNumericalOption(state,"timeout",server.maxidletime,CONFIG_DEFAULT_CLIENT_TIMEOUT);
|
||||
rewriteConfigNumericalOption(state,"tcp-keepalive",server.tcpkeepalive,CONFIG_DEFAULT_TCP_KEEPALIVE);
|
||||
rewriteConfigNumericalOption(state,"timeout",cserver.maxidletime,CONFIG_DEFAULT_CLIENT_TIMEOUT);
|
||||
rewriteConfigNumericalOption(state,"tcp-keepalive",cserver.tcpkeepalive,CONFIG_DEFAULT_TCP_KEEPALIVE);
|
||||
rewriteConfigNumericalOption(state,"replica-announce-port",server.slave_announce_port,CONFIG_DEFAULT_SLAVE_ANNOUNCE_PORT);
|
||||
rewriteConfigEnumOption(state,"loglevel",server.verbosity,loglevel_enum,CONFIG_DEFAULT_VERBOSITY);
|
||||
rewriteConfigEnumOption(state,"loglevel",cserver.verbosity,loglevel_enum,CONFIG_DEFAULT_VERBOSITY);
|
||||
rewriteConfigStringOption(state,"logfile",server.logfile,CONFIG_DEFAULT_LOGFILE);
|
||||
rewriteConfigStringOption(state,"aclfile",server.acl_filename,CONFIG_DEFAULT_ACL_FILENAME);
|
||||
rewriteConfigYesNoOption(state,"syslog-enabled",server.syslog_enabled,CONFIG_DEFAULT_SYSLOG_ENABLED);
|
||||
@ -2300,7 +2300,7 @@ int rewriteConfig(char *path) {
|
||||
rewriteConfigSyslogfacilityOption(state);
|
||||
rewriteConfigSaveOption(state);
|
||||
rewriteConfigUserOption(state);
|
||||
rewriteConfigNumericalOption(state,"databases",server.dbnum,CONFIG_DEFAULT_DBNUM);
|
||||
rewriteConfigNumericalOption(state,"databases",cserver.dbnum,CONFIG_DEFAULT_DBNUM);
|
||||
rewriteConfigYesNoOption(state,"stop-writes-on-bgsave-error",server.stop_writes_on_bgsave_err,CONFIG_DEFAULT_STOP_WRITES_ON_BGSAVE_ERROR);
|
||||
rewriteConfigYesNoOption(state,"rdbcompression",server.rdb_compression,CONFIG_DEFAULT_RDB_COMPRESSION);
|
||||
rewriteConfigYesNoOption(state,"rdbchecksum",server.rdb_checksum,CONFIG_DEFAULT_RDB_CHECKSUM);
|
||||
@ -2308,8 +2308,8 @@ int rewriteConfig(char *path) {
|
||||
rewriteConfigDirOption(state);
|
||||
rewriteConfigSlaveofOption(state,"replicaof");
|
||||
rewriteConfigStringOption(state,"replica-announce-ip",server.slave_announce_ip,CONFIG_DEFAULT_SLAVE_ANNOUNCE_IP);
|
||||
rewriteConfigStringOption(state,"masteruser",server.default_masteruser,NULL);
|
||||
rewriteConfigStringOption(state,"masterauth",server.default_masterauth,NULL);
|
||||
rewriteConfigStringOption(state,"masteruser",cserver.default_masteruser,NULL);
|
||||
rewriteConfigStringOption(state,"masterauth",cserver.default_masterauth,NULL);
|
||||
rewriteConfigStringOption(state,"cluster-announce-ip",server.cluster_announce_ip,NULL);
|
||||
rewriteConfigYesNoOption(state,"replica-serve-stale-data",server.repl_serve_stale_data,CONFIG_DEFAULT_SLAVE_SERVE_STALE_DATA);
|
||||
rewriteConfigYesNoOption(state,"replica-read-only",server.repl_slave_ro,CONFIG_DEFAULT_SLAVE_READ_ONLY);
|
||||
@ -2328,17 +2328,17 @@ int rewriteConfig(char *path) {
|
||||
rewriteConfigNumericalOption(state,"maxclients",server.maxclients,CONFIG_DEFAULT_MAX_CLIENTS);
|
||||
rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,CONFIG_DEFAULT_MAXMEMORY);
|
||||
rewriteConfigBytesOption(state,"proto-max-bulk-len",server.proto_max_bulk_len,CONFIG_DEFAULT_PROTO_MAX_BULK_LEN);
|
||||
rewriteConfigBytesOption(state,"client-query-buffer-limit",server.client_max_querybuf_len,PROTO_MAX_QUERYBUF_LEN);
|
||||
rewriteConfigBytesOption(state,"client-query-buffer-limit",cserver.client_max_querybuf_len,PROTO_MAX_QUERYBUF_LEN);
|
||||
rewriteConfigEnumOption(state,"maxmemory-policy",server.maxmemory_policy,maxmemory_policy_enum,CONFIG_DEFAULT_MAXMEMORY_POLICY);
|
||||
rewriteConfigNumericalOption(state,"maxmemory-samples",server.maxmemory_samples,CONFIG_DEFAULT_MAXMEMORY_SAMPLES);
|
||||
rewriteConfigNumericalOption(state,"lfu-log-factor",server.lfu_log_factor,CONFIG_DEFAULT_LFU_LOG_FACTOR);
|
||||
rewriteConfigNumericalOption(state,"lfu-decay-time",server.lfu_decay_time,CONFIG_DEFAULT_LFU_DECAY_TIME);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-threshold-lower",server.active_defrag_threshold_lower,CONFIG_DEFAULT_DEFRAG_THRESHOLD_LOWER);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-threshold-upper",server.active_defrag_threshold_upper,CONFIG_DEFAULT_DEFRAG_THRESHOLD_UPPER);
|
||||
rewriteConfigBytesOption(state,"active-defrag-ignore-bytes",server.active_defrag_ignore_bytes,CONFIG_DEFAULT_DEFRAG_IGNORE_BYTES);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-cycle-min",server.active_defrag_cycle_min,CONFIG_DEFAULT_DEFRAG_CYCLE_MIN);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-cycle-max",server.active_defrag_cycle_max,CONFIG_DEFAULT_DEFRAG_CYCLE_MAX);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-max-scan-fields",server.active_defrag_max_scan_fields,CONFIG_DEFAULT_DEFRAG_MAX_SCAN_FIELDS);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-threshold-lower",cserver.active_defrag_threshold_lower,CONFIG_DEFAULT_DEFRAG_THRESHOLD_LOWER);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-threshold-upper",cserver.active_defrag_threshold_upper,CONFIG_DEFAULT_DEFRAG_THRESHOLD_UPPER);
|
||||
rewriteConfigBytesOption(state,"active-defrag-ignore-bytes",cserver.active_defrag_ignore_bytes,CONFIG_DEFAULT_DEFRAG_IGNORE_BYTES);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-cycle-min",cserver.active_defrag_cycle_min,CONFIG_DEFAULT_DEFRAG_CYCLE_MIN);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-cycle-max",cserver.active_defrag_cycle_max,CONFIG_DEFAULT_DEFRAG_CYCLE_MAX);
|
||||
rewriteConfigNumericalOption(state,"active-defrag-max-scan-fields",cserver.active_defrag_max_scan_fields,CONFIG_DEFAULT_DEFRAG_MAX_SCAN_FIELDS);
|
||||
rewriteConfigYesNoOption(state,"appendonly",server.aof_state != AOF_OFF,0);
|
||||
rewriteConfigStringOption(state,"appendfilename",server.aof_filename,CONFIG_DEFAULT_AOF_FILENAME);
|
||||
rewriteConfigEnumOption(state,"appendfsync",server.aof_fsync,aof_fsync_enum,CONFIG_DEFAULT_AOF_FSYNC);
|
||||
@ -2368,7 +2368,7 @@ int rewriteConfig(char *path) {
|
||||
rewriteConfigNumericalOption(state,"zset-max-ziplist-value",server.zset_max_ziplist_value,OBJ_ZSET_MAX_ZIPLIST_VALUE);
|
||||
rewriteConfigNumericalOption(state,"hll-sparse-max-bytes",server.hll_sparse_max_bytes,CONFIG_DEFAULT_HLL_SPARSE_MAX_BYTES);
|
||||
rewriteConfigYesNoOption(state,"activerehashing",server.activerehashing,CONFIG_DEFAULT_ACTIVE_REHASHING);
|
||||
rewriteConfigYesNoOption(state,"activedefrag",server.active_defrag_enabled,CONFIG_DEFAULT_ACTIVE_DEFRAG);
|
||||
rewriteConfigYesNoOption(state,"activedefrag",cserver.active_defrag_enabled,CONFIG_DEFAULT_ACTIVE_DEFRAG);
|
||||
rewriteConfigYesNoOption(state,"protected-mode",server.protected_mode,CONFIG_DEFAULT_PROTECTED_MODE);
|
||||
rewriteConfigClientoutputbufferlimitOption(state);
|
||||
rewriteConfigNumericalOption(state,"hz",server.config_hz,CONFIG_DEFAULT_HZ);
|
||||
@ -2376,7 +2376,7 @@ int rewriteConfig(char *path) {
|
||||
rewriteConfigYesNoOption(state,"rdb-save-incremental-fsync",server.rdb_save_incremental_fsync,CONFIG_DEFAULT_RDB_SAVE_INCREMENTAL_FSYNC);
|
||||
rewriteConfigYesNoOption(state,"aof-load-truncated",server.aof_load_truncated,CONFIG_DEFAULT_AOF_LOAD_TRUNCATED);
|
||||
rewriteConfigYesNoOption(state,"aof-use-rdb-preamble",server.aof_use_rdb_preamble,CONFIG_DEFAULT_AOF_USE_RDB_PREAMBLE);
|
||||
rewriteConfigEnumOption(state,"supervised",server.supervised_mode,supervised_mode_enum,SUPERVISED_NONE);
|
||||
rewriteConfigEnumOption(state,"supervised",cserver.supervised_mode,supervised_mode_enum,SUPERVISED_NONE);
|
||||
rewriteConfigYesNoOption(state,"lazyfree-lazy-eviction",server.lazyfree_lazy_eviction,CONFIG_DEFAULT_LAZYFREE_LAZY_EVICTION);
|
||||
rewriteConfigYesNoOption(state,"lazyfree-lazy-expire",server.lazyfree_lazy_expire,CONFIG_DEFAULT_LAZYFREE_LAZY_EXPIRE);
|
||||
rewriteConfigYesNoOption(state,"lazyfree-lazy-server-del",server.lazyfree_lazy_server_del,CONFIG_DEFAULT_LAZYFREE_LAZY_SERVER_DEL);
|
||||
@ -2397,7 +2397,7 @@ int rewriteConfig(char *path) {
|
||||
/* Step 4: generate a new configuration file from the modified state
|
||||
* and write it into the original file. */
|
||||
newcontent = rewriteConfigGetContentFromState(state);
|
||||
retval = rewriteConfigOverwriteFile(server.configfile,newcontent);
|
||||
retval = rewriteConfigOverwriteFile(cserver.configfile,newcontent);
|
||||
|
||||
sdsfree(newcontent);
|
||||
rewriteConfigReleaseState(state);
|
||||
@ -2433,11 +2433,11 @@ NULL
|
||||
resetCommandTableStats();
|
||||
addReply(c,shared.ok);
|
||||
} else if (!strcasecmp(szFromObj(c->argv[1]),"rewrite") && c->argc == 2) {
|
||||
if (server.configfile == NULL) {
|
||||
if (cserver.configfile == NULL) {
|
||||
addReplyError(c,"The server is running without a config file");
|
||||
return;
|
||||
}
|
||||
if (rewriteConfig(server.configfile) == -1) {
|
||||
if (rewriteConfig(cserver.configfile) == -1) {
|
||||
serverLog(LL_WARNING,"CONFIG REWRITE failed: %s", strerror(errno));
|
||||
addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno));
|
||||
} else {
|
||||
|
20
src/db.cpp
20
src/db.cpp
@ -128,10 +128,10 @@ robj_roptr lookupKeyReadWithFlags(redisDb *db, robj *key, int flags) {
|
||||
* will say the key as non existing.
|
||||
*
|
||||
* Notably this covers GETs when slaves are used to scale reads. */
|
||||
if (server.current_client &&
|
||||
!FActiveMaster(server.current_client) &&
|
||||
server.current_client->cmd &&
|
||||
server.current_client->cmd->flags & CMD_READONLY)
|
||||
if (serverTL->current_client &&
|
||||
!FActiveMaster(serverTL->current_client) &&
|
||||
serverTL->current_client->cmd &&
|
||||
serverTL->current_client->cmd->flags & CMD_READONLY)
|
||||
{
|
||||
server.stat_keyspace_misses++;
|
||||
notifyKeyspaceEvent(NOTIFY_KEY_MISS, "keymiss", key, db->id);
|
||||
@ -400,7 +400,7 @@ long long emptyDb(int dbnum, int flags, void(callback)(void*)) {
|
||||
int async = (flags & EMPTYDB_ASYNC);
|
||||
long long removed = 0;
|
||||
|
||||
if (dbnum < -1 || dbnum >= server.dbnum) {
|
||||
if (dbnum < -1 || dbnum >= cserver.dbnum) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
@ -408,7 +408,7 @@ long long emptyDb(int dbnum, int flags, void(callback)(void*)) {
|
||||
int startdb, enddb;
|
||||
if (dbnum == -1) {
|
||||
startdb = 0;
|
||||
enddb = server.dbnum-1;
|
||||
enddb = cserver.dbnum-1;
|
||||
} else {
|
||||
startdb = enddb = dbnum;
|
||||
}
|
||||
@ -434,7 +434,7 @@ long long emptyDb(int dbnum, int flags, void(callback)(void*)) {
|
||||
}
|
||||
|
||||
int selectDb(client *c, int id) {
|
||||
if (id < 0 || id >= server.dbnum)
|
||||
if (id < 0 || id >= cserver.dbnum)
|
||||
return C_ERR;
|
||||
c->db = &server.db[id];
|
||||
return C_OK;
|
||||
@ -1051,8 +1051,8 @@ void scanDatabaseForReadyLists(redisDb *db) {
|
||||
* Returns C_ERR if at least one of the DB ids are out of range, otherwise
|
||||
* C_OK is returned. */
|
||||
int dbSwapDatabases(int id1, int id2) {
|
||||
if (id1 < 0 || id1 >= server.dbnum ||
|
||||
id2 < 0 || id2 >= server.dbnum) return C_ERR;
|
||||
if (id1 < 0 || id1 >= cserver.dbnum ||
|
||||
id2 < 0 || id2 >= cserver.dbnum) return C_ERR;
|
||||
if (id1 == id2) return C_OK;
|
||||
redisDb aux = server.db[id1];
|
||||
redisDb *db1 = &server.db[id1], *db2 = &server.db[id2];
|
||||
@ -1174,7 +1174,7 @@ void propagateExpire(redisDb *db, robj *key, int lazy) {
|
||||
incrRefCount(argv[1]);
|
||||
|
||||
if (server.aof_state != AOF_OFF)
|
||||
feedAppendOnlyFile(server.delCommand,db->id,argv,2);
|
||||
feedAppendOnlyFile(cserver.delCommand,db->id,argv,2);
|
||||
replicationFeedSlaves(server.slaves,db->id,argv,2);
|
||||
|
||||
decrRefCount(argv[0]);
|
||||
|
@ -266,7 +266,7 @@ void computeDatasetDigest(unsigned char *final) {
|
||||
|
||||
memset(final,0,20); /* Start with a clean result */
|
||||
|
||||
for (j = 0; j < server.dbnum; j++) {
|
||||
for (j = 0; j < cserver.dbnum; j++) {
|
||||
redisDb *db = server.db+j;
|
||||
|
||||
if (dictSize(db->pdict) == 0) continue;
|
||||
@ -628,7 +628,7 @@ NULL
|
||||
|
||||
if (getLongFromObjectOrReply(c, c->argv[2], &dbid, NULL) != C_OK)
|
||||
return;
|
||||
if (dbid < 0 || dbid >= server.dbnum) {
|
||||
if (dbid < 0 || dbid >= cserver.dbnum) {
|
||||
addReplyError(c,"Out of range database");
|
||||
return;
|
||||
}
|
||||
@ -1225,9 +1225,9 @@ void logStackTrace(ucontext_t *uc) {
|
||||
* currently being served by Redis. May be NULL if Redis is not serving a
|
||||
* client right now. */
|
||||
void logCurrentClient(void) {
|
||||
if (server.current_client == NULL) return;
|
||||
if (serverTL->current_client == NULL) return;
|
||||
|
||||
client *cc = server.current_client;
|
||||
client *cc = serverTL->current_client;
|
||||
sds client;
|
||||
int j;
|
||||
|
||||
@ -1445,7 +1445,7 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
|
||||
);
|
||||
|
||||
/* free(messages); Don't call free() with possibly corrupted memory. */
|
||||
if (server.daemonize && server.supervised == 0) unlink(server.pidfile);
|
||||
if (cserver.daemonize && cserver.supervised == 0) unlink(cserver.pidfile);
|
||||
|
||||
/* Make sure we exit with the right signal at the end. So for instance
|
||||
* the core will be dumped if enabled. */
|
||||
|
@ -514,7 +514,7 @@ long defragQuicklist(redisDb *db, dictEntry *kde) {
|
||||
serverAssert(ob->type == OBJ_LIST && ob->encoding == OBJ_ENCODING_QUICKLIST);
|
||||
if ((newql = (quicklist*)activeDefragAlloc(ql)))
|
||||
defragged++, ob->m_ptr = ql = newql;
|
||||
if (ql->len > server.active_defrag_max_scan_fields)
|
||||
if (ql->len > cserver.active_defrag_max_scan_fields)
|
||||
defragLater(db, kde);
|
||||
else
|
||||
defragged += activeDefragQuickListNodes(ql);
|
||||
@ -537,7 +537,7 @@ long defragZsetSkiplist(redisDb *db, dictEntry *kde) {
|
||||
defragged++, zs->zsl = newzsl;
|
||||
if ((newheader = (zskiplistNode*)activeDefragAlloc(zs->zsl->header)))
|
||||
defragged++, zs->zsl->header = newheader;
|
||||
if (dictSize(zs->pdict) > server.active_defrag_max_scan_fields)
|
||||
if (dictSize(zs->pdict) > cserver.active_defrag_max_scan_fields)
|
||||
defragLater(db, kde);
|
||||
else {
|
||||
dictIterator *di = dictGetIterator(zs->pdict);
|
||||
@ -560,7 +560,7 @@ long defragHash(redisDb *db, dictEntry *kde) {
|
||||
dict *d, *newd;
|
||||
serverAssert(ob->type == OBJ_HASH && ob->encoding == OBJ_ENCODING_HT);
|
||||
d = (dict*)ptrFromObj(ob);
|
||||
if (dictSize(d) > server.active_defrag_max_scan_fields)
|
||||
if (dictSize(d) > cserver.active_defrag_max_scan_fields)
|
||||
defragLater(db, kde);
|
||||
else
|
||||
defragged += activeDefragSdsDict(d, DEFRAG_SDS_DICT_VAL_IS_SDS);
|
||||
@ -578,7 +578,7 @@ long defragSet(redisDb *db, dictEntry *kde) {
|
||||
dict *d, *newd;
|
||||
serverAssert(ob->type == OBJ_SET && ob->encoding == OBJ_ENCODING_HT);
|
||||
d = (dict*)ptrFromObj(ob);
|
||||
if (dictSize(d) > server.active_defrag_max_scan_fields)
|
||||
if (dictSize(d) > cserver.active_defrag_max_scan_fields)
|
||||
defragLater(db, kde);
|
||||
else
|
||||
defragged += activeDefragSdsDict(d, DEFRAG_SDS_DICT_NO_VAL);
|
||||
@ -742,7 +742,7 @@ long defragStream(redisDb *db, dictEntry *kde) {
|
||||
if ((news = (stream*)activeDefragAlloc(s)))
|
||||
defragged++, ob->m_ptr = s = news;
|
||||
|
||||
if (raxSize(s->prax) > server.active_defrag_max_scan_fields) {
|
||||
if (raxSize(s->prax) > cserver.active_defrag_max_scan_fields) {
|
||||
rax *newrax = (rax*)activeDefragAlloc(s->prax);
|
||||
if (newrax)
|
||||
defragged++, s->prax = newrax;
|
||||
@ -997,19 +997,19 @@ void computeDefragCycles() {
|
||||
float frag_pct = getAllocatorFragmentation(&frag_bytes);
|
||||
/* If we're not already running, and below the threshold, exit. */
|
||||
if (!server.active_defrag_running) {
|
||||
if(frag_pct < server.active_defrag_threshold_lower || frag_bytes < server.active_defrag_ignore_bytes)
|
||||
if(frag_pct < cserver.active_defrag_threshold_lower || frag_bytes < cserver.active_defrag_ignore_bytes)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Calculate the adaptive aggressiveness of the defrag */
|
||||
int cpu_pct = INTERPOLATE(frag_pct,
|
||||
server.active_defrag_threshold_lower,
|
||||
server.active_defrag_threshold_upper,
|
||||
server.active_defrag_cycle_min,
|
||||
server.active_defrag_cycle_max);
|
||||
cserver.active_defrag_threshold_lower,
|
||||
cserver.active_defrag_threshold_upper,
|
||||
cserver.active_defrag_cycle_min,
|
||||
cserver.active_defrag_cycle_max);
|
||||
cpu_pct = LIMIT(cpu_pct,
|
||||
server.active_defrag_cycle_min,
|
||||
server.active_defrag_cycle_max);
|
||||
cserver.active_defrag_cycle_min,
|
||||
cserver.active_defrag_cycle_max);
|
||||
/* We allow increasing the aggressiveness during a scan, but don't
|
||||
* reduce it. */
|
||||
if (!server.active_defrag_running ||
|
||||
@ -1065,7 +1065,7 @@ void activeDefragCycle(void) {
|
||||
}
|
||||
|
||||
/* Move on to next database, and stop if we reached the last one. */
|
||||
if (++current_db >= server.dbnum) {
|
||||
if (++current_db >= cserver.dbnum) {
|
||||
/* defrag other items not part of the db / keys */
|
||||
defragOtherGlobals();
|
||||
|
||||
|
@ -488,7 +488,7 @@ int freeMemoryIfNeeded(void) {
|
||||
/* We don't want to make local-db choices when expiring keys,
|
||||
* so to start populate the eviction pool sampling keys from
|
||||
* every DB. */
|
||||
for (i = 0; i < server.dbnum; i++) {
|
||||
for (i = 0; i < cserver.dbnum; i++) {
|
||||
db = server.db+i;
|
||||
dict = (server.maxmemory_policy & MAXMEMORY_FLAG_ALLKEYS) ?
|
||||
db->pdict : db->expires;
|
||||
@ -537,8 +537,8 @@ int freeMemoryIfNeeded(void) {
|
||||
/* When evicting a random key, we try to evict a key for
|
||||
* each DB, so we use the static 'next_db' variable to
|
||||
* incrementally visit all DBs. */
|
||||
for (i = 0; i < server.dbnum; i++) {
|
||||
j = (++next_db) % server.dbnum;
|
||||
for (i = 0; i < cserver.dbnum; i++) {
|
||||
j = (++next_db) % cserver.dbnum;
|
||||
db = server.db+j;
|
||||
dict = (server.maxmemory_policy == MAXMEMORY_ALLKEYS_RANDOM) ?
|
||||
db->pdict : db->expires;
|
||||
|
@ -126,8 +126,8 @@ void activeExpireCycle(int type) {
|
||||
* 2) If last time we hit the time limit, we want to scan all DBs
|
||||
* in this iteration, as there is work to do in some DB and we don't want
|
||||
* expired keys to use memory for too much time. */
|
||||
if (dbs_per_call > server.dbnum || timelimit_exit)
|
||||
dbs_per_call = server.dbnum;
|
||||
if (dbs_per_call > cserver.dbnum || timelimit_exit)
|
||||
dbs_per_call = cserver.dbnum;
|
||||
|
||||
/* We can use at max ACTIVE_EXPIRE_CYCLE_SLOW_TIME_PERC percentage of CPU time
|
||||
* per iteration. Since this function gets called with a frequency of
|
||||
@ -148,7 +148,7 @@ void activeExpireCycle(int type) {
|
||||
|
||||
for (j = 0; j < dbs_per_call && timelimit_exit == 0; j++) {
|
||||
int expired;
|
||||
redisDb *db = server.db+(current_db % server.dbnum);
|
||||
redisDb *db = server.db+(current_db % cserver.dbnum);
|
||||
|
||||
/* Increment the DB now so we are sure if we run out of time
|
||||
* in the current DB we'll restart from the next. This allows to
|
||||
@ -297,7 +297,7 @@ void expireSlaveKeys(void) {
|
||||
/* Check the key against every database corresponding to the
|
||||
* bits set in the value bitmap. */
|
||||
int dbid = 0;
|
||||
while(dbids && dbid < server.dbnum) {
|
||||
while(dbids && dbid < cserver.dbnum) {
|
||||
if ((dbids & 1) != 0) {
|
||||
redisDb *db = server.db+dbid;
|
||||
dictEntry *expire = dictFind(db->expires,keyname);
|
||||
|
@ -528,7 +528,7 @@ void moduleHandlePropagationAfterCommandCallback(RedisModuleCtx *ctx) {
|
||||
if (ctx->flags & REDISMODULE_CTX_MULTI_EMITTED) {
|
||||
robj *propargv[1];
|
||||
propargv[0] = createStringObject("EXEC",4);
|
||||
alsoPropagate(server.execCommand,c->db->id,propargv,1,
|
||||
alsoPropagate(cserver.execCommand,c->db->id,propargv,1,
|
||||
PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(propargv[0]);
|
||||
}
|
||||
@ -3507,7 +3507,7 @@ void RM_LogRaw(RedisModule *module, const char *levelstr, const char *fmt, va_li
|
||||
else if (!strcasecmp(levelstr,"warning")) level = LL_WARNING;
|
||||
else level = LL_VERBOSE; /* Default. */
|
||||
|
||||
if (level < server.verbosity) return;
|
||||
if (level < cserver.verbosity) return;
|
||||
|
||||
name_len = snprintf(msg, sizeof(msg),"<%s> ", module->name);
|
||||
vsnprintf(msg + name_len, sizeof(msg) - name_len, fmt, ap);
|
||||
|
@ -111,7 +111,7 @@ void discardCommand(client *c) {
|
||||
void execCommandPropagateMulti(client *c) {
|
||||
robj *multistring = createStringObject("MULTI",5);
|
||||
|
||||
propagate(server.multiCommand,c->db->id,&multistring,1,
|
||||
propagate(cserver.multiCommand,c->db->id,&multistring,1,
|
||||
PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(multistring);
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ client *createClient(int fd, int iel) {
|
||||
if (fd != -1) {
|
||||
anetNonBlock(NULL,fd);
|
||||
anetEnableTcpNoDelay(NULL,fd);
|
||||
if (server.tcpkeepalive)
|
||||
anetKeepAlive(NULL,fd,server.tcpkeepalive);
|
||||
if (cserver.tcpkeepalive)
|
||||
anetKeepAlive(NULL,fd,cserver.tcpkeepalive);
|
||||
if (aeCreateFileEvent(server.rgthreadvar[iel].el,fd,AE_READABLE|AE_READ_THREADSAFE,
|
||||
readQueryFromClient, c) == AE_ERR)
|
||||
{
|
||||
@ -1042,7 +1042,7 @@ static void acceptCommonHandler(int fd, int flags, char *ip, int iel) {
|
||||
|
||||
#ifdef HAVE_SO_INCOMING_CPU
|
||||
// Set thread affinity
|
||||
if (server.fThreadAffinity)
|
||||
if (cserver.fThreadAffinity)
|
||||
{
|
||||
int cpu = iel;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, sizeof(iel)) != 0)
|
||||
@ -1200,7 +1200,7 @@ void unlinkClient(client *c) {
|
||||
serverAssert(c->fd == -1 || c->lock.fOwnLock());
|
||||
|
||||
/* If this is marked as current client unset it. */
|
||||
if (server.current_client == c) server.current_client = NULL;
|
||||
if (serverTL->current_client == c) serverTL->current_client = NULL;
|
||||
|
||||
/* Certain operations must be done only if the client has an active socket.
|
||||
* If the client was already unlinked or if it's a "fake client" the
|
||||
@ -1254,7 +1254,7 @@ void unlinkClient(client *c) {
|
||||
if (c->fPendingAsyncWrite) {
|
||||
ln = NULL;
|
||||
bool fFound = false;
|
||||
for (int iel = 0; iel < server.cthreads; ++iel)
|
||||
for (int iel = 0; iel < cserver.cthreads; ++iel)
|
||||
{
|
||||
ln = listSearchKey(server.rgthreadvar[iel].clients_pending_asyncwrite,c);
|
||||
if (ln)
|
||||
@ -1779,7 +1779,7 @@ int processInlineBuffer(client *c) {
|
||||
* and set the client as CLIENT_CLOSE_AFTER_REPLY. */
|
||||
#define PROTO_DUMP_LEN 128
|
||||
static void setProtocolError(const char *errstr, client *c) {
|
||||
if (server.verbosity <= LL_VERBOSE) {
|
||||
if (cserver.verbosity <= LL_VERBOSE) {
|
||||
sds client = catClientInfoString(sdsempty(),c);
|
||||
|
||||
/* Sample some protocol to given an idea about what was inside. */
|
||||
@ -2003,7 +2003,7 @@ void processInputBuffer(client *c, int callFlags) {
|
||||
} else {
|
||||
AeLocker locker;
|
||||
locker.arm(c);
|
||||
server.current_client = c;
|
||||
serverTL->current_client = c;
|
||||
|
||||
/* Only reset the client when the command was executed. */
|
||||
if (processCommand(c, callFlags) == C_OK) {
|
||||
@ -2022,11 +2022,11 @@ void processInputBuffer(client *c, int callFlags) {
|
||||
/* freeMemoryIfNeeded may flush slave output buffers. This may
|
||||
* result into a slave, that may be the active client, to be
|
||||
* freed. */
|
||||
if (server.current_client == NULL) {
|
||||
if (serverTL->current_client == NULL) {
|
||||
fFreed = true;
|
||||
break;
|
||||
}
|
||||
server.current_client = NULL;
|
||||
serverTL->current_client = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2127,7 +2127,7 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||
c->lastinteraction = server.unixtime;
|
||||
if (c->flags & CLIENT_MASTER) c->read_reploff += nread;
|
||||
server.stat_net_input_bytes += nread;
|
||||
if (sdslen(c->querybuf) > server.client_max_querybuf_len) {
|
||||
if (sdslen(c->querybuf) > cserver.client_max_querybuf_len) {
|
||||
sds ci = catClientInfoString(sdsempty(),c), bytes = sdsempty();
|
||||
|
||||
bytes = sdscatrepr(bytes,c->querybuf,64);
|
||||
@ -2739,11 +2739,11 @@ int checkClientOutputBufferLimits(client *c) {
|
||||
* like normal clients. */
|
||||
if (clientType == CLIENT_TYPE_MASTER) clientType = CLIENT_TYPE_NORMAL;
|
||||
|
||||
if (server.client_obuf_limits[clientType].hard_limit_bytes &&
|
||||
used_mem >= server.client_obuf_limits[clientType].hard_limit_bytes)
|
||||
if (cserver.client_obuf_limits[clientType].hard_limit_bytes &&
|
||||
used_mem >= cserver.client_obuf_limits[clientType].hard_limit_bytes)
|
||||
hard = 1;
|
||||
if (server.client_obuf_limits[clientType].soft_limit_bytes &&
|
||||
used_mem >= server.client_obuf_limits[clientType].soft_limit_bytes)
|
||||
if (cserver.client_obuf_limits[clientType].soft_limit_bytes &&
|
||||
used_mem >= cserver.client_obuf_limits[clientType].soft_limit_bytes)
|
||||
soft = 1;
|
||||
|
||||
/* We need to check if the soft limit is reached continuously for the
|
||||
@ -2756,7 +2756,7 @@ int checkClientOutputBufferLimits(client *c) {
|
||||
time_t elapsed = server.unixtime - c->obuf_soft_limit_reached_time;
|
||||
|
||||
if (elapsed <=
|
||||
server.client_obuf_limits[clientType].soft_limit_seconds) {
|
||||
cserver.client_obuf_limits[clientType].soft_limit_seconds) {
|
||||
soft = 0; /* The client still did not reached the max number of
|
||||
seconds for the soft limit to be considered
|
||||
reached. */
|
||||
|
@ -1049,7 +1049,7 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
|
||||
mh->lua_caches = mem;
|
||||
mem_total+=mem;
|
||||
|
||||
for (j = 0; j < server.dbnum; j++) {
|
||||
for (j = 0; j < cserver.dbnum; j++) {
|
||||
redisDb *db = server.db+j;
|
||||
long long keyscount = dictSize(db->pdict);
|
||||
if (keyscount==0) continue;
|
||||
|
@ -1118,7 +1118,7 @@ int rdbSaveRio(rio *rdb, int *error, int flags, rdbSaveInfo *rsi) {
|
||||
if (rdbWriteRaw(rdb,magic,9) == -1) goto werr;
|
||||
if (rdbSaveInfoAuxFields(rdb,flags,rsi) == -1) goto werr;
|
||||
|
||||
for (j = 0; j < server.dbnum; j++) {
|
||||
for (j = 0; j < cserver.dbnum; j++) {
|
||||
redisDb *db = server.db+j;
|
||||
dict *d = db->pdict;
|
||||
if (dictSize(d) == 0) continue;
|
||||
@ -1947,11 +1947,11 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi, int loading_aof) {
|
||||
} else if (type == RDB_OPCODE_SELECTDB) {
|
||||
/* SELECTDB: Select the specified database. */
|
||||
if ((dbid = rdbLoadLen(rdb,NULL)) == RDB_LENERR) goto eoferr;
|
||||
if (dbid >= (unsigned)server.dbnum) {
|
||||
if (dbid >= (unsigned)cserver.dbnum) {
|
||||
serverLog(LL_WARNING,
|
||||
"FATAL: Data file was created with a Redis "
|
||||
"server configured to handle more than %d "
|
||||
"databases. Exiting\n", server.dbnum);
|
||||
"databases. Exiting\n", cserver.dbnum);
|
||||
exit(1);
|
||||
}
|
||||
db = server.db+dbid;
|
||||
|
@ -345,7 +345,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
|
||||
serverAssert(cchbuf > 0);
|
||||
|
||||
char uuid[40] = {'\0'};
|
||||
uuid_unparse(server.uuid, uuid);
|
||||
uuid_unparse(cserver.uuid, uuid);
|
||||
char proto[1024];
|
||||
int cchProto = snprintf(proto, sizeof(proto), "*3\r\n$7\r\nRREPLAY\r\n$%d\r\n%s\r\n$%lld\r\n", (int)strlen(uuid), uuid, cchbuf);
|
||||
cchProto = std::min((int)sizeof(proto), cchProto);
|
||||
@ -357,7 +357,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
|
||||
|
||||
/* Don't feed slaves that are still waiting for BGSAVE to start */
|
||||
if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) continue;
|
||||
if (server.current_client && FSameHost(server.current_client, slave)) continue;
|
||||
if (serverTL->current_client && FSameHost(serverTL->current_client, slave)) continue;
|
||||
std::unique_lock<decltype(slave->lock)> lock(slave->lock);
|
||||
|
||||
if (!fSendRaw)
|
||||
@ -903,7 +903,7 @@ void processReplconfUuid(client *c, robj *arg)
|
||||
|
||||
char szServerUUID[36 + 2]; // 1 for the '+', another for '\0'
|
||||
szServerUUID[0] = '+';
|
||||
uuid_unparse(server.uuid, szServerUUID+1);
|
||||
uuid_unparse(cserver.uuid, szServerUUID+1);
|
||||
addReplyProto(c, szServerUUID, 37);
|
||||
addReplyProto(c, "\r\n", 2);
|
||||
return;
|
||||
@ -1910,7 +1910,7 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||
if (mi->repl_state == REPL_STATE_SEND_UUID) {
|
||||
char szUUID[37] = {0};
|
||||
memset(mi->master_uuid, 0, UUID_BINARY_LEN);
|
||||
uuid_unparse((unsigned char*)server.uuid, szUUID);
|
||||
uuid_unparse((unsigned char*)cserver.uuid, szUUID);
|
||||
err = sendSynchronousCommand(mi, SYNC_CMD_WRITE,fd,"REPLCONF","uuid",szUUID,NULL);
|
||||
if (err) goto write_error;
|
||||
mi->repl_state = REPL_STATE_RECEIVE_UUID;
|
||||
@ -3187,7 +3187,7 @@ void replicaReplayCommand(client *c)
|
||||
{
|
||||
static thread_local ReplicaNestState *s_pstate = nullptr;
|
||||
if (s_pstate == nullptr)
|
||||
s_pstate = new ReplicaNestState;
|
||||
s_pstate = new (MALLOC_LOCAL) ReplicaNestState;
|
||||
|
||||
// the replay command contains two arguments:
|
||||
// 1: The UUID of the source
|
||||
@ -3224,7 +3224,7 @@ void replicaReplayCommand(client *c)
|
||||
return;
|
||||
}
|
||||
|
||||
if (FSameUuidNoNil(uuid, server.uuid))
|
||||
if (FSameUuidNoNil(uuid, cserver.uuid))
|
||||
{
|
||||
addReply(c, shared.ok);
|
||||
s_pstate->Cancel();
|
||||
@ -3248,7 +3248,7 @@ void replicaReplayCommand(client *c)
|
||||
|
||||
// call() will not propogate this for us, so we do so here
|
||||
if (!s_pstate->FCancelled() && s_pstate->FFirst())
|
||||
alsoPropagate(server.rreplayCommand,c->db->id,c->argv,c->argc,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
alsoPropagate(cserver.rreplayCommand,c->db->id,c->argv,c->argc,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
|
||||
s_pstate->Pop();
|
||||
return;
|
||||
@ -3266,9 +3266,9 @@ void updateMasterAuth()
|
||||
zfree(mi->masterauth); mi->masterauth = nullptr;
|
||||
zfree(mi->masteruser); mi->masteruser = nullptr;
|
||||
|
||||
if (server.default_masterauth)
|
||||
mi->masterauth = zstrdup(server.default_masterauth);
|
||||
if (server.default_masteruser)
|
||||
mi->masteruser = zstrdup(server.default_masteruser);
|
||||
if (cserver.default_masterauth)
|
||||
mi->masterauth = zstrdup(cserver.default_masterauth);
|
||||
if (cserver.default_masteruser)
|
||||
mi->masteruser = zstrdup(cserver.default_masteruser);
|
||||
}
|
||||
}
|
@ -1472,7 +1472,7 @@ void evalGenericCommand(client *c, int evalsha) {
|
||||
if (server.lua_multi_emitted) {
|
||||
robj *propargv[1];
|
||||
propargv[0] = createStringObject("EXEC",4);
|
||||
alsoPropagate(server.execCommand,c->db->id,propargv,1,
|
||||
alsoPropagate(cserver.execCommand,c->db->id,propargv,1,
|
||||
PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(propargv[0]);
|
||||
}
|
||||
|
@ -504,14 +504,14 @@ void initSentinel(void) {
|
||||
void sentinelIsRunning(void) {
|
||||
int j;
|
||||
|
||||
if (server.configfile == NULL) {
|
||||
if (cserver.configfile == NULL) {
|
||||
serverLog(LL_WARNING,
|
||||
"Sentinel started without a config file. Exiting...");
|
||||
exit(1);
|
||||
} else if (access(server.configfile,W_OK) == -1) {
|
||||
} else if (access(cserver.configfile,W_OK) == -1) {
|
||||
serverLog(LL_WARNING,
|
||||
"Sentinel config file %s is not writable: %s. Exiting...",
|
||||
server.configfile,strerror(errno));
|
||||
cserver.configfile,strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ void sentinelEvent(int level, const char *type, sentinelRedisInstance *ri,
|
||||
}
|
||||
|
||||
/* Log the message if the log level allows it to be logged. */
|
||||
if (level >= server.verbosity)
|
||||
if (level >= cserver.verbosity)
|
||||
serverLog(level,"%s %s",type,msg);
|
||||
|
||||
/* Publish the message via Pub/Sub if it's not a debugging one. */
|
||||
@ -1930,11 +1930,11 @@ void sentinelFlushConfig(void) {
|
||||
int rewrite_status;
|
||||
|
||||
server.hz = CONFIG_DEFAULT_HZ;
|
||||
rewrite_status = rewriteConfig(server.configfile);
|
||||
rewrite_status = rewriteConfig(cserver.configfile);
|
||||
server.hz = saved_hz;
|
||||
|
||||
if (rewrite_status == -1) goto werr;
|
||||
if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr;
|
||||
if ((fd = open(cserver.configfile,O_RDONLY)) == -1) goto werr;
|
||||
if (fsync(fd) == -1) goto werr;
|
||||
if (close(fd) == EOF) goto werr;
|
||||
return;
|
||||
|
202
src/server.cpp
202
src/server.cpp
@ -74,6 +74,7 @@ double R_Zero, R_PosInf, R_NegInf, R_Nan;
|
||||
|
||||
/* Global vars */
|
||||
struct redisServer server; /* Server global state */
|
||||
struct redisServerConst cserver;
|
||||
__thread struct redisServerThreadVars *serverTL = NULL; // thread local server vars
|
||||
volatile unsigned long lru_clock; /* Server global current LRU time. */
|
||||
|
||||
@ -1023,7 +1024,7 @@ void serverLogRaw(int level, const char *msg) {
|
||||
int log_to_stdout = server.logfile[0] == '\0';
|
||||
|
||||
level &= 0xff; /* clear flags */
|
||||
if (level < server.verbosity) return;
|
||||
if (level < cserver.verbosity) return;
|
||||
|
||||
fp = log_to_stdout ? stdout : fopen(server.logfile,"a");
|
||||
if (!fp) return;
|
||||
@ -1043,7 +1044,7 @@ void serverLogRaw(int level, const char *msg) {
|
||||
snprintf(buf+off,sizeof(buf)-off,"%03d",(int)tv.tv_usec/1000);
|
||||
if (server.sentinel_mode) {
|
||||
role_char = 'X'; /* Sentinel. */
|
||||
} else if (pid != server.pid) {
|
||||
} else if (pid != cserver.pid) {
|
||||
role_char = 'C'; /* RDB / AOF writing child. */
|
||||
} else {
|
||||
role_char = (listLength(server.masters) ? 'S':'M'); /* Slave or Master. */
|
||||
@ -1064,7 +1065,7 @@ void serverLog(int level, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
char msg[LOG_MAX_LEN];
|
||||
|
||||
if ((level&0xff) < server.verbosity) return;
|
||||
if ((level&0xff) < cserver.verbosity) return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, sizeof(msg), fmt, ap);
|
||||
@ -1084,7 +1085,7 @@ void serverLogFromHandler(int level, const char *msg) {
|
||||
int log_to_stdout = server.logfile[0] == '\0';
|
||||
char buf[64];
|
||||
|
||||
if ((level&0xff) < server.verbosity || (log_to_stdout && server.daemonize))
|
||||
if ((level&0xff) < cserver.verbosity || (log_to_stdout && cserver.daemonize))
|
||||
return;
|
||||
fd = log_to_stdout ? STDOUT_FILENO :
|
||||
open(server.logfile, O_APPEND|O_CREAT|O_WRONLY, 0644);
|
||||
@ -1495,12 +1496,12 @@ long long getInstantaneousMetric(int metric) {
|
||||
int clientsCronHandleTimeout(client *c, mstime_t now_ms) {
|
||||
time_t now = now_ms/1000;
|
||||
|
||||
if (server.maxidletime &&
|
||||
if (cserver.maxidletime &&
|
||||
!(c->flags & CLIENT_SLAVE) && /* no timeout for slaves */
|
||||
!(c->flags & CLIENT_MASTER) && /* no timeout for masters */
|
||||
!(c->flags & CLIENT_BLOCKED) && /* no timeout for BLPOP */
|
||||
!(c->flags & CLIENT_PUBSUB) && /* no timeout for Pub/Sub clients */
|
||||
(now - c->lastinteraction > server.maxidletime))
|
||||
(now - c->lastinteraction > cserver.maxidletime))
|
||||
{
|
||||
serverLog(LL_VERBOSE,"Closing idle client");
|
||||
freeClient(c);
|
||||
@ -1694,7 +1695,7 @@ void databasesCron(void) {
|
||||
}
|
||||
|
||||
/* Defrag keys gradually. */
|
||||
if (server.active_defrag_enabled)
|
||||
if (cserver.active_defrag_enabled)
|
||||
activeDefragCycle();
|
||||
|
||||
/* Perform hash tables rehashing if needed, but only if there are no
|
||||
@ -1710,11 +1711,11 @@ void databasesCron(void) {
|
||||
int j;
|
||||
|
||||
/* Don't test more DBs than we have. */
|
||||
if (dbs_per_call > server.dbnum) dbs_per_call = server.dbnum;
|
||||
if (dbs_per_call > cserver.dbnum) dbs_per_call = cserver.dbnum;
|
||||
|
||||
/* Resize */
|
||||
for (j = 0; j < dbs_per_call; j++) {
|
||||
tryResizeHashTables(resize_db % server.dbnum);
|
||||
tryResizeHashTables(resize_db % cserver.dbnum);
|
||||
resize_db++;
|
||||
}
|
||||
|
||||
@ -1729,7 +1730,7 @@ void databasesCron(void) {
|
||||
} else {
|
||||
/* If this db didn't need rehash, we'll try the next one. */
|
||||
rehash_db++;
|
||||
rehash_db %= server.dbnum;
|
||||
rehash_db %= cserver.dbnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1867,7 +1868,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
||||
|
||||
/* Show some info about non-empty databases */
|
||||
run_with_period(5000) {
|
||||
for (j = 0; j < server.dbnum; j++) {
|
||||
for (j = 0; j < cserver.dbnum; j++) {
|
||||
long long size, used, vkeys;
|
||||
|
||||
size = dictSlots(server.db[j].pdict);
|
||||
@ -2256,13 +2257,13 @@ void createSharedObjects(void) {
|
||||
|
||||
void initMasterInfo(redisMaster *master)
|
||||
{
|
||||
if (server.default_masterauth)
|
||||
master->masterauth = zstrdup(server.default_masterauth);
|
||||
if (cserver.default_masterauth)
|
||||
master->masterauth = zstrdup(cserver.default_masterauth);
|
||||
else
|
||||
master->masterauth = NULL;
|
||||
|
||||
if (server.default_masteruser)
|
||||
master->masteruser = zstrdup(server.default_masteruser);
|
||||
if (cserver.default_masteruser)
|
||||
master->masteruser = zstrdup(cserver.default_masteruser);
|
||||
else
|
||||
master->masteruser = NULL;
|
||||
|
||||
@ -2292,11 +2293,10 @@ void initServerConfig(void) {
|
||||
server.slaves = listCreate();
|
||||
server.monitors = listCreate();
|
||||
server.timezone = getTimeZone(); /* Initialized by tzset(). */
|
||||
server.configfile = NULL;
|
||||
server.executable = NULL;
|
||||
cserver.configfile = NULL;
|
||||
cserver.executable = NULL;
|
||||
server.hz = server.config_hz = CONFIG_DEFAULT_HZ;
|
||||
server.dynamic_hz = CONFIG_DEFAULT_DYNAMIC_HZ;
|
||||
server.arch_bits = (sizeof(long) == 8) ? 64 : 32;
|
||||
server.port = CONFIG_DEFAULT_SERVER_PORT;
|
||||
server.tcp_backlog = CONFIG_DEFAULT_TCP_BACKLOG;
|
||||
server.bindaddr_count = 0;
|
||||
@ -2304,29 +2304,29 @@ void initServerConfig(void) {
|
||||
server.unixsocketperm = CONFIG_DEFAULT_UNIX_SOCKET_PERM;
|
||||
server.sofd = -1;
|
||||
server.protected_mode = CONFIG_DEFAULT_PROTECTED_MODE;
|
||||
server.dbnum = CONFIG_DEFAULT_DBNUM;
|
||||
server.verbosity = CONFIG_DEFAULT_VERBOSITY;
|
||||
server.maxidletime = CONFIG_DEFAULT_CLIENT_TIMEOUT;
|
||||
server.tcpkeepalive = CONFIG_DEFAULT_TCP_KEEPALIVE;
|
||||
cserver.dbnum = CONFIG_DEFAULT_DBNUM;
|
||||
cserver.verbosity = CONFIG_DEFAULT_VERBOSITY;
|
||||
cserver.maxidletime = CONFIG_DEFAULT_CLIENT_TIMEOUT;
|
||||
cserver.tcpkeepalive = CONFIG_DEFAULT_TCP_KEEPALIVE;
|
||||
server.active_expire_enabled = 1;
|
||||
server.active_defrag_enabled = CONFIG_DEFAULT_ACTIVE_DEFRAG;
|
||||
server.active_defrag_ignore_bytes = CONFIG_DEFAULT_DEFRAG_IGNORE_BYTES;
|
||||
server.active_defrag_threshold_lower = CONFIG_DEFAULT_DEFRAG_THRESHOLD_LOWER;
|
||||
server.active_defrag_threshold_upper = CONFIG_DEFAULT_DEFRAG_THRESHOLD_UPPER;
|
||||
server.active_defrag_cycle_min = CONFIG_DEFAULT_DEFRAG_CYCLE_MIN;
|
||||
server.active_defrag_cycle_max = CONFIG_DEFAULT_DEFRAG_CYCLE_MAX;
|
||||
server.active_defrag_max_scan_fields = CONFIG_DEFAULT_DEFRAG_MAX_SCAN_FIELDS;
|
||||
cserver.active_defrag_enabled = CONFIG_DEFAULT_ACTIVE_DEFRAG;
|
||||
cserver.active_defrag_ignore_bytes = CONFIG_DEFAULT_DEFRAG_IGNORE_BYTES;
|
||||
cserver.active_defrag_threshold_lower = CONFIG_DEFAULT_DEFRAG_THRESHOLD_LOWER;
|
||||
cserver.active_defrag_threshold_upper = CONFIG_DEFAULT_DEFRAG_THRESHOLD_UPPER;
|
||||
cserver.active_defrag_cycle_min = CONFIG_DEFAULT_DEFRAG_CYCLE_MIN;
|
||||
cserver.active_defrag_cycle_max = CONFIG_DEFAULT_DEFRAG_CYCLE_MAX;
|
||||
cserver.active_defrag_max_scan_fields = CONFIG_DEFAULT_DEFRAG_MAX_SCAN_FIELDS;
|
||||
server.proto_max_bulk_len = CONFIG_DEFAULT_PROTO_MAX_BULK_LEN;
|
||||
server.client_max_querybuf_len = PROTO_MAX_QUERYBUF_LEN;
|
||||
cserver.client_max_querybuf_len = PROTO_MAX_QUERYBUF_LEN;
|
||||
server.saveparams = NULL;
|
||||
server.loading = 0;
|
||||
server.logfile = zstrdup(CONFIG_DEFAULT_LOGFILE);
|
||||
server.syslog_enabled = CONFIG_DEFAULT_SYSLOG_ENABLED;
|
||||
server.syslog_ident = zstrdup(CONFIG_DEFAULT_SYSLOG_IDENT);
|
||||
server.syslog_facility = LOG_LOCAL0;
|
||||
server.daemonize = CONFIG_DEFAULT_DAEMONIZE;
|
||||
server.supervised = 0;
|
||||
server.supervised_mode = SUPERVISED_NONE;
|
||||
cserver.daemonize = CONFIG_DEFAULT_DAEMONIZE;
|
||||
cserver.supervised = 0;
|
||||
cserver.supervised_mode = SUPERVISED_NONE;
|
||||
server.aof_state = AOF_OFF;
|
||||
server.aof_fsync = CONFIG_DEFAULT_AOF_FSYNC;
|
||||
server.aof_no_fsync_on_rewrite = CONFIG_DEFAULT_AOF_NO_FSYNC_ON_REWRITE;
|
||||
@ -2346,7 +2346,7 @@ void initServerConfig(void) {
|
||||
server.rdb_save_incremental_fsync = CONFIG_DEFAULT_RDB_SAVE_INCREMENTAL_FSYNC;
|
||||
server.aof_load_truncated = CONFIG_DEFAULT_AOF_LOAD_TRUNCATED;
|
||||
server.aof_use_rdb_preamble = CONFIG_DEFAULT_AOF_USE_RDB_PREAMBLE;
|
||||
server.pidfile = NULL;
|
||||
cserver.pidfile = NULL;
|
||||
server.rdb_filename = NULL;
|
||||
server.rdb_s3bucketpath = NULL;
|
||||
server.aof_filename = zstrdup(CONFIG_DEFAULT_AOF_FILENAME);
|
||||
@ -2437,7 +2437,7 @@ void initServerConfig(void) {
|
||||
|
||||
/* Client output buffer limits */
|
||||
for (j = 0; j < CLIENT_TYPE_OBUF_COUNT; j++)
|
||||
server.client_obuf_limits[j] = clientBufferLimitsDefaults[j];
|
||||
cserver.client_obuf_limits[j] = clientBufferLimitsDefaults[j];
|
||||
|
||||
/* Double constants initialization */
|
||||
R_Zero = 0.0;
|
||||
@ -2451,20 +2451,20 @@ void initServerConfig(void) {
|
||||
server.commands = dictCreate(&commandTableDictType,NULL);
|
||||
server.orig_commands = dictCreate(&commandTableDictType,NULL);
|
||||
populateCommandTable();
|
||||
server.delCommand = lookupCommandByCString("del");
|
||||
server.multiCommand = lookupCommandByCString("multi");
|
||||
server.lpushCommand = lookupCommandByCString("lpush");
|
||||
server.lpopCommand = lookupCommandByCString("lpop");
|
||||
server.rpopCommand = lookupCommandByCString("rpop");
|
||||
server.zpopminCommand = lookupCommandByCString("zpopmin");
|
||||
server.zpopmaxCommand = lookupCommandByCString("zpopmax");
|
||||
server.sremCommand = lookupCommandByCString("srem");
|
||||
server.execCommand = lookupCommandByCString("exec");
|
||||
server.expireCommand = lookupCommandByCString("expire");
|
||||
server.pexpireCommand = lookupCommandByCString("pexpire");
|
||||
server.xclaimCommand = lookupCommandByCString("xclaim");
|
||||
server.xgroupCommand = lookupCommandByCString("xgroup");
|
||||
server.rreplayCommand = lookupCommandByCString("rreplay");
|
||||
cserver.delCommand = lookupCommandByCString("del");
|
||||
cserver.multiCommand = lookupCommandByCString("multi");
|
||||
cserver.lpushCommand = lookupCommandByCString("lpush");
|
||||
cserver.lpopCommand = lookupCommandByCString("lpop");
|
||||
cserver.rpopCommand = lookupCommandByCString("rpop");
|
||||
cserver.zpopminCommand = lookupCommandByCString("zpopmin");
|
||||
cserver.zpopmaxCommand = lookupCommandByCString("zpopmax");
|
||||
cserver.sremCommand = lookupCommandByCString("srem");
|
||||
cserver.execCommand = lookupCommandByCString("exec");
|
||||
cserver.expireCommand = lookupCommandByCString("expire");
|
||||
cserver.pexpireCommand = lookupCommandByCString("pexpire");
|
||||
cserver.xclaimCommand = lookupCommandByCString("xclaim");
|
||||
cserver.xgroupCommand = lookupCommandByCString("xgroup");
|
||||
cserver.rreplayCommand = lookupCommandByCString("rreplay");
|
||||
|
||||
/* Slow log */
|
||||
server.slowlog_log_slower_than = CONFIG_DEFAULT_SLOWLOG_LOG_SLOWER_THAN;
|
||||
@ -2487,13 +2487,13 @@ void initServerConfig(void) {
|
||||
server.lua_always_replicate_commands = 1;
|
||||
|
||||
/* Multithreading */
|
||||
server.cthreads = CONFIG_DEFAULT_THREADS;
|
||||
server.fThreadAffinity = CONFIG_DEFAULT_THREAD_AFFINITY;
|
||||
cserver.cthreads = CONFIG_DEFAULT_THREADS;
|
||||
cserver.fThreadAffinity = CONFIG_DEFAULT_THREAD_AFFINITY;
|
||||
|
||||
server.db = (redisDb*)zmalloc(sizeof(redisDb)*server.dbnum, MALLOC_LOCAL);
|
||||
server.db = (redisDb*)zmalloc(sizeof(redisDb)*cserver.dbnum, MALLOC_LOCAL);
|
||||
|
||||
/* Create the Redis databases, and initialize other internal state. */
|
||||
for (int j = 0; j < server.dbnum; j++) {
|
||||
for (int j = 0; j < cserver.dbnum; j++) {
|
||||
server.db[j].pdict = dictCreate(&dbDictType,NULL);
|
||||
server.db[j].expires = dictCreate(&keyptrDictType,NULL);
|
||||
server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL);
|
||||
@ -2527,16 +2527,16 @@ int restartServer(int flags, mstime_t delay) {
|
||||
|
||||
/* Check if we still have accesses to the executable that started this
|
||||
* server instance. */
|
||||
if (access(server.executable,X_OK) == -1) {
|
||||
if (access(cserver.executable,X_OK) == -1) {
|
||||
serverLog(LL_WARNING,"Can't restart: this process has no "
|
||||
"permissions to execute %s", server.executable);
|
||||
"permissions to execute %s", cserver.executable);
|
||||
return C_ERR;
|
||||
}
|
||||
|
||||
/* Config rewriting. */
|
||||
if (flags & RESTART_SERVER_CONFIG_REWRITE &&
|
||||
server.configfile &&
|
||||
rewriteConfig(server.configfile) == -1)
|
||||
cserver.configfile &&
|
||||
rewriteConfig(cserver.configfile) == -1)
|
||||
{
|
||||
serverLog(LL_WARNING,"Can't restart: configuration rewrite process "
|
||||
"failed");
|
||||
@ -2561,9 +2561,9 @@ int restartServer(int flags, mstime_t delay) {
|
||||
|
||||
/* Execute the server with the original command line. */
|
||||
if (delay) usleep(delay*1000);
|
||||
zfree(server.exec_argv[0]);
|
||||
server.exec_argv[0] = zstrdup(server.executable);
|
||||
execve(server.executable,server.exec_argv,environ);
|
||||
zfree(cserver.exec_argv[0]);
|
||||
cserver.exec_argv[0] = zstrdup(cserver.executable);
|
||||
execve(cserver.executable,cserver.exec_argv,environ);
|
||||
|
||||
/* If an error occurred here, there is nothing we can do, but exit. */
|
||||
_exit(1);
|
||||
@ -2818,7 +2818,7 @@ static void initNetworkingThread(int iel, int fReusePort)
|
||||
|
||||
static void initNetworking(int fReusePort)
|
||||
{
|
||||
int celListen = (fReusePort) ? server.cthreads : 1;
|
||||
int celListen = (fReusePort) ? cserver.cthreads : 1;
|
||||
for (int iel = 0; iel < celListen; ++iel)
|
||||
initNetworkingThread(iel, fReusePort);
|
||||
|
||||
@ -2852,6 +2852,7 @@ static void initServerThread(struct redisServerThreadVars *pvar, int fMain)
|
||||
pvar->ipfd_count = 0;
|
||||
pvar->cclients = 0;
|
||||
pvar->el = aeCreateEventLoop(server.maxclients+CONFIG_FDSET_INCR);
|
||||
pvar->current_client = nullptr;
|
||||
if (pvar->el == NULL) {
|
||||
serverLog(LL_WARNING,
|
||||
"Failed creating the event loop. Error message: '%s'",
|
||||
@ -2883,8 +2884,7 @@ void initServer(void) {
|
||||
}
|
||||
|
||||
server.hz = server.config_hz;
|
||||
server.pid = getpid();
|
||||
server.current_client = NULL;
|
||||
cserver.pid = getpid();
|
||||
server.clients_index = raxNew();
|
||||
server.clients_to_close = listCreate();
|
||||
server.slaveseldb = -1; /* Force to emit the first SELECT command. */
|
||||
@ -2892,7 +2892,7 @@ void initServer(void) {
|
||||
server.clients_waiting_acks = listCreate();
|
||||
server.get_ack_from_slaves = 0;
|
||||
server.clients_paused = 0;
|
||||
server.system_memory_size = zmalloc_get_memory_size();
|
||||
cserver.system_memory_size = zmalloc_get_memory_size();
|
||||
|
||||
createSharedObjects();
|
||||
adjustOpenFilesLimit();
|
||||
@ -2919,7 +2919,7 @@ void initServer(void) {
|
||||
server.dirty = 0;
|
||||
resetServerStats();
|
||||
/* A few stats we don't want to reset: server startup time, and peak mem. */
|
||||
server.stat_starttime = time(NULL);
|
||||
cserver.stat_starttime = time(NULL);
|
||||
server.stat_peak_memory = 0;
|
||||
server.stat_rdb_cow_bytes = 0;
|
||||
server.stat_aof_cow_bytes = 0;
|
||||
@ -2977,15 +2977,15 @@ void initServer(void) {
|
||||
* no explicit limit in the user provided configuration we set a limit
|
||||
* at 3 GB using maxmemory with 'noeviction' policy'. This avoids
|
||||
* useless crashes of the Redis instance for out of memory. */
|
||||
if (server.arch_bits == 32 && server.maxmemory == 0) {
|
||||
if (sizeof(void*) == 4 && server.maxmemory == 0) {
|
||||
serverLog(LL_WARNING,"Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.");
|
||||
server.maxmemory = 3072LL*(1024*1024); /* 3 GB */
|
||||
server.maxmemory_policy = MAXMEMORY_NO_EVICTION;
|
||||
}
|
||||
|
||||
/* Generate UUID */
|
||||
static_assert(sizeof(uuid_t) == sizeof(server.uuid), "UUIDs are standardized at 16-bytes");
|
||||
uuid_generate((unsigned char*)server.uuid);
|
||||
static_assert(sizeof(uuid_t) == sizeof(cserver.uuid), "UUIDs are standardized at 16-bytes");
|
||||
uuid_generate((unsigned char*)cserver.uuid);
|
||||
|
||||
if (server.cluster_enabled) clusterInit();
|
||||
replicationScriptCacheInit();
|
||||
@ -3513,7 +3513,7 @@ int processCommand(client *c, int callFlags) {
|
||||
int out_of_memory = freeMemoryIfNeededAndSafe() == C_ERR;
|
||||
/* freeMemoryIfNeeded may flush slave output buffers. This may result
|
||||
* into a slave, that may be the active client, to be freed. */
|
||||
if (server.current_client == NULL) return C_ERR;
|
||||
if (serverTL->current_client == NULL) return C_ERR;
|
||||
|
||||
/* It was impossible to free enough memory, and the command the client
|
||||
* is trying to execute is denied during OOM conditions or the client
|
||||
@ -3640,7 +3640,7 @@ int processCommand(client *c, int callFlags) {
|
||||
void closeListeningSockets(int unlink_unix_socket) {
|
||||
int j;
|
||||
|
||||
for (int iel = 0; iel < server.cthreads; ++iel)
|
||||
for (int iel = 0; iel < cserver.cthreads; ++iel)
|
||||
{
|
||||
for (j = 0; j < server.rgthreadvar[iel].ipfd_count; j++)
|
||||
close(server.rgthreadvar[iel].ipfd[j]);
|
||||
@ -3709,9 +3709,9 @@ int prepareForShutdown(int flags) {
|
||||
}
|
||||
|
||||
/* Remove the pid file if possible and needed. */
|
||||
if (server.daemonize || server.pidfile) {
|
||||
if (cserver.daemonize || cserver.pidfile) {
|
||||
serverLog(LL_NOTICE,"Removing the pid file.");
|
||||
unlink(server.pidfile);
|
||||
unlink(cserver.pidfile);
|
||||
}
|
||||
|
||||
/* Best effort flush of slave output buffers, so that we hopefully
|
||||
@ -3936,7 +3936,7 @@ void bytesToHuman(char *s, unsigned long long n) {
|
||||
* on memory corruption problems. */
|
||||
sds genRedisInfoString(const char *section) {
|
||||
sds info = sdsempty();
|
||||
time_t uptime = server.unixtime-server.stat_starttime;
|
||||
time_t uptime = server.unixtime-cserver.stat_starttime;
|
||||
int j;
|
||||
struct rusage self_ru, c_ru;
|
||||
int allsections = 0, defsections = 0;
|
||||
@ -3997,7 +3997,7 @@ sds genRedisInfoString(const char *section) {
|
||||
(unsigned long long) redisBuildId(),
|
||||
mode,
|
||||
name.sysname, name.release, name.machine,
|
||||
server.arch_bits,
|
||||
(int)sizeof(void*)*8,
|
||||
aeGetApiName(),
|
||||
REDIS_ATOMIC_API,
|
||||
#ifdef __GNUC__
|
||||
@ -4013,8 +4013,8 @@ sds genRedisInfoString(const char *section) {
|
||||
server.hz,
|
||||
server.config_hz,
|
||||
(unsigned long) lruclock,
|
||||
server.executable ? server.executable : "",
|
||||
server.configfile ? server.configfile : "");
|
||||
cserver.executable ? cserver.executable : "",
|
||||
cserver.configfile ? cserver.configfile : "");
|
||||
}
|
||||
|
||||
/* Clients */
|
||||
@ -4031,7 +4031,7 @@ sds genRedisInfoString(const char *section) {
|
||||
listLength(server.clients)-listLength(server.slaves),
|
||||
maxin, maxout,
|
||||
server.blocked_clients);
|
||||
for (int ithread = 0; ithread < server.cthreads; ++ithread)
|
||||
for (int ithread = 0; ithread < cserver.cthreads; ++ithread)
|
||||
{
|
||||
info = sdscatprintf(info,
|
||||
"thread_%d_clients:%d\r\n",
|
||||
@ -4049,7 +4049,7 @@ sds genRedisInfoString(const char *section) {
|
||||
char used_memory_rss_hmem[64];
|
||||
char maxmemory_hmem[64];
|
||||
size_t zmalloc_used = zmalloc_used_memory();
|
||||
size_t total_system_mem = server.system_memory_size;
|
||||
size_t total_system_mem = cserver.system_memory_size;
|
||||
const char *evict_policy = evictPolicyToString();
|
||||
long long memory_lua = (long long)lua_gc(server.lua,LUA_GCCOUNT,0)*1024;
|
||||
struct redisMemOverhead *mh = getMemoryOverheadData();
|
||||
@ -4459,7 +4459,7 @@ sds genRedisInfoString(const char *section) {
|
||||
(long)self_ru.ru_utime.tv_sec, (long)self_ru.ru_utime.tv_usec,
|
||||
(long)c_ru.ru_stime.tv_sec, (long)c_ru.ru_stime.tv_usec,
|
||||
(long)c_ru.ru_utime.tv_sec, (long)c_ru.ru_utime.tv_usec,
|
||||
server.cthreads,
|
||||
cserver.cthreads,
|
||||
fastlock_getlongwaitcount());
|
||||
}
|
||||
|
||||
@ -4496,7 +4496,7 @@ sds genRedisInfoString(const char *section) {
|
||||
if (allsections || defsections || !strcasecmp(section,"keyspace")) {
|
||||
if (sections++) info = sdscat(info,"\r\n");
|
||||
info = sdscatprintf(info, "# Keyspace\r\n");
|
||||
for (j = 0; j < server.dbnum; j++) {
|
||||
for (j = 0; j < cserver.dbnum; j++) {
|
||||
long long keys, vkeys;
|
||||
|
||||
keys = dictSize(server.db[j].pdict);
|
||||
@ -4561,10 +4561,10 @@ void linuxMemoryWarnings(void) {
|
||||
void createPidFile(void) {
|
||||
/* If pidfile requested, but no pidfile defined, use
|
||||
* default pidfile path */
|
||||
if (!server.pidfile) server.pidfile = zstrdup(CONFIG_DEFAULT_PID_FILE);
|
||||
if (!cserver.pidfile) cserver.pidfile = zstrdup(CONFIG_DEFAULT_PID_FILE);
|
||||
|
||||
/* Try to write the pid file in a best-effort way. */
|
||||
FILE *fp = fopen(server.pidfile,"w");
|
||||
FILE *fp = fopen(cserver.pidfile,"w");
|
||||
if (fp) {
|
||||
fprintf(fp,"%d\n",(int)getpid());
|
||||
fclose(fp);
|
||||
@ -4977,10 +4977,10 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* Store the executable path and arguments in a safe place in order
|
||||
* to be able to restart the server later. */
|
||||
server.executable = getAbsolutePath(argv[0]);
|
||||
server.exec_argv = (char**)zmalloc(sizeof(char*)*(argc+1), MALLOC_LOCAL);
|
||||
server.exec_argv[argc] = NULL;
|
||||
for (j = 0; j < argc; j++) server.exec_argv[j] = zstrdup(argv[j]);
|
||||
cserver.executable = getAbsolutePath(argv[0]);
|
||||
cserver.exec_argv = (char**)zmalloc(sizeof(char*)*(argc+1), MALLOC_LOCAL);
|
||||
cserver.exec_argv[argc] = NULL;
|
||||
for (j = 0; j < argc; j++) cserver.exec_argv[j] = zstrdup(argv[j]);
|
||||
|
||||
/* We need to init sentinel right now as parsing the configuration file
|
||||
* in sentinel mode will have the effect of populating the sentinel
|
||||
@ -5022,11 +5022,11 @@ int main(int argc, char **argv) {
|
||||
/* First argument is the config file name? */
|
||||
if (argv[j][0] != '-' || argv[j][1] != '-') {
|
||||
configfile = argv[j];
|
||||
server.configfile = getAbsolutePath(configfile);
|
||||
cserver.configfile = getAbsolutePath(configfile);
|
||||
/* Replace the config file in server.exec_argv with
|
||||
* its absolute path. */
|
||||
zfree(server.exec_argv[j]);
|
||||
server.exec_argv[j] = zstrdup(server.configfile);
|
||||
zfree(cserver.exec_argv[j]);
|
||||
cserver.exec_argv[j] = zstrdup(cserver.configfile);
|
||||
j++;
|
||||
}
|
||||
|
||||
@ -5079,20 +5079,20 @@ int main(int argc, char **argv) {
|
||||
serverLog(LL_WARNING, "Configuration loaded");
|
||||
}
|
||||
|
||||
if (server.cthreads > (int)std::thread::hardware_concurrency()) {
|
||||
if (cserver.cthreads > (int)std::thread::hardware_concurrency()) {
|
||||
serverLog(LL_WARNING, "WARNING: server-threads is greater than this machine's core count. Truncating to %u threads", std::thread::hardware_concurrency());
|
||||
server.cthreads = (int)std::thread::hardware_concurrency();
|
||||
server.cthreads = std::max(server.cthreads, 1); // in case of any weird sign overflows
|
||||
cserver.cthreads = (int)std::thread::hardware_concurrency();
|
||||
cserver.cthreads = std::max(cserver.cthreads, 1); // in case of any weird sign overflows
|
||||
}
|
||||
|
||||
server.supervised = redisIsSupervised(server.supervised_mode);
|
||||
int background = server.daemonize && !server.supervised;
|
||||
cserver.supervised = redisIsSupervised(cserver.supervised_mode);
|
||||
int background = cserver.daemonize && !cserver.supervised;
|
||||
if (background) daemonize();
|
||||
|
||||
initServer();
|
||||
initNetworking(server.cthreads > 1 /* fReusePort */);
|
||||
initNetworking(cserver.cthreads > 1 /* fReusePort */);
|
||||
|
||||
if (background || server.pidfile) createPidFile();
|
||||
if (background || cserver.pidfile) createPidFile();
|
||||
redisSetProcTitle(argv[0]);
|
||||
redisAsciiArt();
|
||||
checkTcpBacklogSettings();
|
||||
@ -5130,8 +5130,8 @@ int main(int argc, char **argv) {
|
||||
server.repl_diskless_sync = TRUE;
|
||||
}
|
||||
|
||||
if (server.cthreads > 4) {
|
||||
serverLog(LL_WARNING, "Warning: server-threads is set to %d. This is above the maximum recommend value of 4, please ensure you've verified this is actually faster on your machine.", server.cthreads);
|
||||
if (cserver.cthreads > 4) {
|
||||
serverLog(LL_WARNING, "Warning: server-threads is set to %d. This is above the maximum recommend value of 4, please ensure you've verified this is actually faster on your machine.", cserver.cthreads);
|
||||
}
|
||||
|
||||
/* Warning the user about suspicious maxmemory setting. */
|
||||
@ -5141,12 +5141,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
aeReleaseLock(); //Finally we can dump the lock
|
||||
|
||||
serverAssert(server.cthreads > 0 && server.cthreads <= MAX_EVENT_LOOPS);
|
||||
serverAssert(cserver.cthreads > 0 && cserver.cthreads <= MAX_EVENT_LOOPS);
|
||||
pthread_t rgthread[MAX_EVENT_LOOPS];
|
||||
for (int iel = 0; iel < server.cthreads; ++iel)
|
||||
for (int iel = 0; iel < cserver.cthreads; ++iel)
|
||||
{
|
||||
pthread_create(rgthread + iel, NULL, workerThreadMain, (void*)((int64_t)iel));
|
||||
if (server.fThreadAffinity)
|
||||
if (cserver.fThreadAffinity)
|
||||
{
|
||||
#ifdef __linux__
|
||||
cpu_set_t cpuset;
|
||||
|
93
src/server.h
93
src/server.h
@ -1144,6 +1144,7 @@ struct redisServerThreadVars {
|
||||
list *unblocked_clients; /* list of clients to unblock before next loop NOT THREADSAFE */
|
||||
list *clients_pending_asyncwrite;
|
||||
int cclients;
|
||||
client *current_client; /* Current client */
|
||||
struct fastlock lockPendingWrite;
|
||||
};
|
||||
|
||||
@ -1174,12 +1175,53 @@ struct redisMaster {
|
||||
/* After we've connected with our master use the UUID in server.master */
|
||||
};
|
||||
|
||||
struct redisServer {
|
||||
/* General */
|
||||
// Const vars are not changed after worker threads are launched
|
||||
struct redisServerConst {
|
||||
pid_t pid; /* Main process pid. */
|
||||
time_t stat_starttime; /* Server start time */
|
||||
char *configfile; /* Absolute config file path, or NULL */
|
||||
char *executable; /* Absolute executable file path. */
|
||||
char **exec_argv; /* Executable argv vector (copy). */
|
||||
|
||||
int cthreads; /* Number of main worker threads */
|
||||
int fThreadAffinity; /* Should we pin threads to cores? */
|
||||
char *pidfile; /* PID file path */
|
||||
|
||||
/* Fast pointers to often looked up command */
|
||||
struct redisCommand *delCommand, *multiCommand, *lpushCommand,
|
||||
*lpopCommand, *rpopCommand, *zpopminCommand,
|
||||
*zpopmaxCommand, *sremCommand, *execCommand,
|
||||
*expireCommand, *pexpireCommand, *xclaimCommand,
|
||||
*xgroupCommand, *rreplayCommand;
|
||||
|
||||
/* Configuration */
|
||||
char *default_masteruser; /* AUTH with this user and masterauth with master */
|
||||
char *default_masterauth; /* AUTH with this password with master */
|
||||
int verbosity; /* Loglevel in redis.conf */
|
||||
int maxidletime; /* Client timeout in seconds */
|
||||
int tcpkeepalive; /* Set SO_KEEPALIVE if non-zero. */
|
||||
int active_defrag_enabled;
|
||||
size_t active_defrag_ignore_bytes; /* minimum amount of fragmentation waste to start active defrag */
|
||||
int active_defrag_threshold_lower; /* minimum percentage of fragmentation to start active defrag */
|
||||
int active_defrag_threshold_upper; /* maximum percentage of fragmentation at which we use maximum effort */
|
||||
int active_defrag_cycle_min; /* minimal effort for defrag in CPU percentage */
|
||||
int active_defrag_cycle_max; /* maximal effort for defrag in CPU percentage */
|
||||
unsigned long active_defrag_max_scan_fields; /* maximum number of fields of set/hash/zset/list to process from within the main dict scan */
|
||||
size_t client_max_querybuf_len; /* Limit for client query buffer length */
|
||||
int dbnum; /* Total number of configured DBs */
|
||||
int supervised; /* 1 if supervised, 0 otherwise. */
|
||||
int supervised_mode; /* See SUPERVISED_* */
|
||||
int daemonize; /* True if running as a daemon */
|
||||
clientBufferLimitsConfig client_obuf_limits[CLIENT_TYPE_OBUF_COUNT];
|
||||
|
||||
/* System hardware info */
|
||||
size_t system_memory_size; /* Total memory in system as reported by OS */
|
||||
|
||||
unsigned char uuid[UUID_BINARY_LEN]; /* This server's UUID - populated on boot */
|
||||
};
|
||||
|
||||
struct redisServer {
|
||||
/* General */
|
||||
int dynamic_hz; /* Change hz value depending on # of clients. */
|
||||
int config_hz; /* Configured HZ value. May be different than
|
||||
the actual 'hz' field value if dynamic-hz
|
||||
@ -1189,16 +1231,12 @@ struct redisServer {
|
||||
dict *commands; /* Command table */
|
||||
dict *orig_commands; /* Command table before command renaming. */
|
||||
|
||||
int cthreads; /* Number of main worker threads */
|
||||
int fThreadAffinity; /* Should we pin threads to cores? */
|
||||
struct redisServerThreadVars rgthreadvar[MAX_EVENT_LOOPS];
|
||||
|
||||
unsigned int lruclock; /* Clock for LRU eviction */
|
||||
int shutdown_asap; /* SHUTDOWN needed ASAP */
|
||||
int activerehashing; /* Incremental rehash in serverCron() */
|
||||
int active_defrag_running; /* Active defragmentation running (holds current scan aggressiveness) */
|
||||
char *pidfile; /* PID file path */
|
||||
int arch_bits; /* 32 or 64 depending on sizeof(long) */
|
||||
int cronloops; /* Number of times the cron function run */
|
||||
char runid[CONFIG_RUN_ID_SIZE+1]; /* ID always different at every exec. */
|
||||
int sentinel_mode; /* True if this instance is a Sentinel. */
|
||||
@ -1225,7 +1263,6 @@ struct redisServer {
|
||||
list *clients; /* List of active clients */
|
||||
list *clients_to_close; /* Clients to close asynchronously */
|
||||
list *slaves, *monitors; /* List of slaves and MONITORs */
|
||||
client *current_client; /* Current client, only used on crash report */
|
||||
rax *clients_index; /* Active clients dictionary by client ID. */
|
||||
int clients_paused; /* True if clients are currently paused */
|
||||
mstime_t clients_pause_end_time; /* Time when we undo clients_paused */
|
||||
@ -1239,14 +1276,10 @@ struct redisServer {
|
||||
off_t loading_loaded_bytes;
|
||||
time_t loading_start_time;
|
||||
off_t loading_process_events_interval_bytes;
|
||||
/* Fast pointers to often looked up command */
|
||||
struct redisCommand *delCommand, *multiCommand, *lpushCommand,
|
||||
*lpopCommand, *rpopCommand, *zpopminCommand,
|
||||
*zpopmaxCommand, *sremCommand, *execCommand,
|
||||
*expireCommand, *pexpireCommand, *xclaimCommand,
|
||||
*xgroupCommand, *rreplayCommand;
|
||||
|
||||
int active_expire_enabled; /* Can be disabled for testing purposes. */
|
||||
|
||||
/* Fields used only for stats */
|
||||
time_t stat_starttime; /* Server start time */
|
||||
long long stat_numcommands; /* Number of processed commands */
|
||||
long long stat_numconnections; /* Number of connections received */
|
||||
long long stat_expiredkeys; /* Number of expired keys */
|
||||
@ -1284,26 +1317,7 @@ struct redisServer {
|
||||
long long samples[STATS_METRIC_SAMPLES];
|
||||
int idx;
|
||||
} inst_metric[STATS_METRIC_COUNT];
|
||||
/* Configuration */
|
||||
char *default_masteruser; /* AUTH with this user and masterauth with master */
|
||||
char *default_masterauth; /* AUTH with this password with master */
|
||||
int verbosity; /* Loglevel in redis.conf */
|
||||
int maxidletime; /* Client timeout in seconds */
|
||||
int tcpkeepalive; /* Set SO_KEEPALIVE if non-zero. */
|
||||
int active_expire_enabled; /* Can be disabled for testing purposes. */
|
||||
int active_defrag_enabled;
|
||||
size_t active_defrag_ignore_bytes; /* minimum amount of fragmentation waste to start active defrag */
|
||||
int active_defrag_threshold_lower; /* minimum percentage of fragmentation to start active defrag */
|
||||
int active_defrag_threshold_upper; /* maximum percentage of fragmentation at which we use maximum effort */
|
||||
int active_defrag_cycle_min; /* minimal effort for defrag in CPU percentage */
|
||||
int active_defrag_cycle_max; /* maximal effort for defrag in CPU percentage */
|
||||
unsigned long active_defrag_max_scan_fields; /* maximum number of fields of set/hash/zset/list to process from within the main dict scan */
|
||||
size_t client_max_querybuf_len; /* Limit for client query buffer length */
|
||||
int dbnum; /* Total number of configured DBs */
|
||||
int supervised; /* 1 if supervised, 0 otherwise. */
|
||||
int supervised_mode; /* See SUPERVISED_* */
|
||||
int daemonize; /* True if running as a daemon */
|
||||
clientBufferLimitsConfig client_obuf_limits[CLIENT_TYPE_OBUF_COUNT];
|
||||
|
||||
/* AOF persistence */
|
||||
int aof_state; /* AOF_(ON|OFF|WAIT_REWRITE) */
|
||||
int aof_fsync; /* Kind of fsync() policy */
|
||||
@ -1511,8 +1525,6 @@ struct redisServer {
|
||||
int assert_line;
|
||||
int bug_report_start; /* True if bug report header was already logged. */
|
||||
int watchdog_period; /* Software watchdog period in ms. 0 = off */
|
||||
/* System hardware info */
|
||||
size_t system_memory_size; /* Total memory in system as reported by OS */
|
||||
|
||||
/* Mutexes used to protect atomic variables when atomic builtins are
|
||||
* not available. */
|
||||
@ -1521,7 +1533,6 @@ struct redisServer {
|
||||
pthread_mutex_t unixtime_mutex;
|
||||
|
||||
int fActiveReplica; /* Can this replica also be a master? */
|
||||
unsigned char uuid[UUID_BINARY_LEN]; /* This server's UUID - populated on boot */
|
||||
|
||||
struct fastlock flock;
|
||||
|
||||
@ -1622,7 +1633,9 @@ typedef struct {
|
||||
* Extern declarations
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern struct redisServer server;
|
||||
//extern struct redisServer server;
|
||||
extern redisServer *g_pserver;
|
||||
extern struct redisServerConst cserver;
|
||||
extern __thread struct redisServerThreadVars *serverTL; // thread local server vars
|
||||
extern struct sharedObjectsStruct shared;
|
||||
extern dictType objectKeyPointerValueDictType;
|
||||
@ -2488,12 +2501,12 @@ static inline int GlobalLocksAcquired(void) // Used in asserts to verify all gl
|
||||
inline int ielFromEventLoop(const aeEventLoop *eventLoop)
|
||||
{
|
||||
int iel = 0;
|
||||
for (; iel < server.cthreads; ++iel)
|
||||
for (; iel < cserver.cthreads; ++iel)
|
||||
{
|
||||
if (server.rgthreadvar[iel].el == eventLoop)
|
||||
break;
|
||||
}
|
||||
serverAssert(iel < server.cthreads);
|
||||
serverAssert(iel < cserver.cthreads);
|
||||
return iel;
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb
|
||||
shared.rpop;
|
||||
argv[1] = key;
|
||||
propagate((where == LIST_HEAD) ?
|
||||
server.lpopCommand : server.rpopCommand,
|
||||
cserver.lpopCommand : cserver.rpopCommand,
|
||||
db->id,argv,2,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
|
||||
/* BRPOP/BLPOP */
|
||||
@ -659,7 +659,7 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb
|
||||
/* Propagate the RPOP operation. */
|
||||
argv[0] = shared.rpop;
|
||||
argv[1] = key;
|
||||
propagate(server.rpopCommand,
|
||||
propagate(cserver.rpopCommand,
|
||||
db->id,argv,2,
|
||||
PROPAGATE_AOF|
|
||||
PROPAGATE_REPL);
|
||||
@ -669,7 +669,7 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb
|
||||
argv[0] = shared.lpush;
|
||||
argv[1] = dstkey;
|
||||
argv[2] = value;
|
||||
propagate(server.lpushCommand,
|
||||
propagate(cserver.lpushCommand,
|
||||
db->id,argv,3,
|
||||
PROPAGATE_AOF|
|
||||
PROPAGATE_REPL);
|
||||
|
@ -492,7 +492,7 @@ void spopWithCountCommand(client *c) {
|
||||
|
||||
/* Replicate/AOF this command as an SREM operation */
|
||||
propargv[2] = objele;
|
||||
alsoPropagate(server.sremCommand,c->db->id,propargv,3,
|
||||
alsoPropagate(cserver.sremCommand,c->db->id,propargv,3,
|
||||
PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(objele);
|
||||
}
|
||||
@ -535,7 +535,7 @@ void spopWithCountCommand(client *c) {
|
||||
|
||||
/* Replicate/AOF this command as an SREM operation */
|
||||
propargv[2] = objele;
|
||||
alsoPropagate(server.sremCommand,c->db->id,propargv,3,
|
||||
alsoPropagate(cserver.sremCommand,c->db->id,propargv,3,
|
||||
PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(objele);
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ void streamPropagateXCLAIM(client *c, robj *key, streamCG *group, robj *groupnam
|
||||
argv[11] = createStringObject("JUSTID",6);
|
||||
argv[12] = createStringObject("LASTID",6);
|
||||
argv[13] = createObjectFromStreamID(&group->last_id);
|
||||
propagate(server.xclaimCommand,c->db->id,argv,14,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
propagate(cserver.xclaimCommand,c->db->id,argv,14,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(argv[0]);
|
||||
decrRefCount(argv[3]);
|
||||
decrRefCount(argv[4]);
|
||||
@ -846,7 +846,7 @@ void streamPropagateGroupID(client *c, robj *key, streamCG *group, robj *groupna
|
||||
argv[2] = key;
|
||||
argv[3] = groupname;
|
||||
argv[4] = createObjectFromStreamID(&group->last_id);
|
||||
propagate(server.xgroupCommand,c->db->id,argv,5,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
propagate(cserver.xgroupCommand,c->db->id,argv,5,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
decrRefCount(argv[0]);
|
||||
decrRefCount(argv[1]);
|
||||
decrRefCount(argv[4]);
|
||||
|
@ -120,4 +120,8 @@ int zmalloc_test(int argc, char **argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "new.h"
|
||||
#endif
|
||||
|
||||
#endif /* __ZMALLOC_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user