mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 01:20:50 +00:00
CONFIG REWRITE: support for client-output-buffer-limit.
This commit is contained in:
parent
d95592b116
commit
c184f36d21
46
src/config.c
46
src/config.c
@ -47,6 +47,12 @@ static struct {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
clientBufferLimitsConfig clientBufferLimitsDefaults[REDIS_CLIENT_LIMIT_NUM_CLASSES] = {
|
||||
{0, 0, 0}, /* normal */
|
||||
{1024*1024*256, 1024*1024*64, 60}, /* slave */
|
||||
{1024*1024*32, 1024*1024*8, 60} /* pubsub */
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Config file parsing
|
||||
*----------------------------------------------------------------------------*/
|
||||
@ -1336,23 +1342,59 @@ void rewriteConfigDirOption(struct rewriteConfigState *state) {
|
||||
}
|
||||
|
||||
void rewriteConfigSlaveofOption(struct rewriteConfigState *state) {
|
||||
char *option = "slaveof";
|
||||
sds line;
|
||||
|
||||
/* If this is a master, we want all the slaveof config options
|
||||
* in the file to be removed. */
|
||||
if (server.masterhost == NULL) return;
|
||||
line = sdscatprintf(sdsempty(),"slaveof %s %d",
|
||||
line = sdscatprintf(sdsempty(),"%s %s %d", option,
|
||||
server.masterhost, server.masterport);
|
||||
rewriteConfigRewriteLine(state,"slaveof",line,1);
|
||||
rewriteConfigRewriteLine(state,option,line,1);
|
||||
}
|
||||
|
||||
void rewriteConfigAppendonlyOption(struct rewriteConfigState *state) {
|
||||
int force = server.aof_state != REDIS_AOF_OFF;
|
||||
char *option = "appendonly";
|
||||
sds line;
|
||||
|
||||
line = sdscatprintf(sdsempty(),"%s %s", option,
|
||||
(server.aof_state == REDIS_AOF_OFF) ? "no" : "yes");
|
||||
rewriteConfigRewriteLine(state,option,line,force);
|
||||
}
|
||||
|
||||
void rewriteConfigNotifykeyspaceeventsOption(struct rewriteConfigState *state) {
|
||||
int force = server.notify_keyspace_events != 0;
|
||||
char *option = "notify-keyspace-events";
|
||||
sds line, flags;
|
||||
|
||||
flags = keyspaceEventsFlagsToString(server.notify_keyspace_events);
|
||||
line = sdscatprintf(sdsempty(),"%s %s", option, flags);
|
||||
sdsfree(flags);
|
||||
rewriteConfigRewriteLine(state,option,line,force);
|
||||
}
|
||||
|
||||
void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state) {
|
||||
int j;
|
||||
char *option = "client-output-buffer-limit";
|
||||
|
||||
for (j = 0; j < REDIS_CLIENT_LIMIT_NUM_CLASSES; j++) {
|
||||
int force = (server.client_obuf_limits[j].hard_limit_bytes !=
|
||||
clientBufferLimitsDefaults[j].hard_limit_bytes) ||
|
||||
(server.client_obuf_limits[j].soft_limit_bytes !=
|
||||
clientBufferLimitsDefaults[j].soft_limit_bytes) ||
|
||||
(server.client_obuf_limits[j].soft_limit_seconds !=
|
||||
clientBufferLimitsDefaults[j].soft_limit_seconds);
|
||||
sds line;
|
||||
|
||||
line = sdscatprintf(sdsempty(),"%s %s %llu %llu %ld",
|
||||
option,
|
||||
getClientLimitClassName(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);
|
||||
rewriteConfigRewriteLine(state,option,line,force);
|
||||
}
|
||||
}
|
||||
|
||||
sds rewriteConfigGetContentFromState(struct rewriteConfigState *state) {
|
||||
|
13
src/redis.c
13
src/redis.c
@ -1198,6 +1198,8 @@ void createSharedObjects(void) {
|
||||
}
|
||||
|
||||
void initServerConfig() {
|
||||
int j;
|
||||
|
||||
getRandomHexChars(server.runid,REDIS_RUN_ID_SIZE);
|
||||
server.configfile = NULL;
|
||||
server.hz = REDIS_DEFAULT_HZ;
|
||||
@ -1303,15 +1305,8 @@ void initServerConfig() {
|
||||
server.repl_no_slaves_since = time(NULL);
|
||||
|
||||
/* Client output buffer limits */
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_NORMAL].hard_limit_bytes = 0;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_NORMAL].soft_limit_bytes = 0;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_NORMAL].soft_limit_seconds = 0;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_SLAVE].hard_limit_bytes = 1024*1024*256;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_SLAVE].soft_limit_bytes = 1024*1024*64;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_SLAVE].soft_limit_seconds = 60;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_PUBSUB].hard_limit_bytes = 1024*1024*32;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_PUBSUB].soft_limit_bytes = 1024*1024*8;
|
||||
server.client_obuf_limits[REDIS_CLIENT_LIMIT_CLASS_PUBSUB].soft_limit_seconds = 60;
|
||||
for (j = 0; j < REDIS_CLIENT_LIMIT_NUM_CLASSES; j++)
|
||||
server.client_obuf_limits[j] = clientBufferLimitsDefaults[j];
|
||||
|
||||
/* Double constants initialization */
|
||||
R_Zero = 0.0;
|
||||
|
@ -493,6 +493,8 @@ typedef struct clientBufferLimitsConfig {
|
||||
time_t soft_limit_seconds;
|
||||
} clientBufferLimitsConfig;
|
||||
|
||||
extern clientBufferLimitsConfig clientBufferLimitsDefaults[REDIS_CLIENT_LIMIT_NUM_CLASSES];
|
||||
|
||||
/* The redisOp structure defines a Redis Operation, that is an instance of
|
||||
* a command with an argument vector, database ID, propagation target
|
||||
* (REDIS_PROPAGATE_*), and command pointer.
|
||||
|
Loading…
x
Reference in New Issue
Block a user