summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-05-13 18:34:18 +0200
committerantirez <antirez@gmail.com>2013-05-13 18:34:18 +0200
commitc184f36d21cae47a4b9b4484b657d2e58fdc4f58 (patch)
treef29cdd5661b77067b7b8e6f612697c99757c88cb
parentd95592b11689130382d7bf71aedf8963cc7f7431 (diff)
downloadredis-c184f36d21cae47a4b9b4484b657d2e58fdc4f58.tar.gz
CONFIG REWRITE: support for client-output-buffer-limit.
-rw-r--r--src/config.c46
-rw-r--r--src/redis.c13
-rw-r--r--src/redis.h2
3 files changed, 50 insertions, 11 deletions
diff --git a/src/config.c b/src/config.c
index 52c4dca1f..5d72081ca 100644
--- a/src/config.c
+++ b/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) {
diff --git a/src/redis.c b/src/redis.c
index ecbb1e4a7..5baa75006 100644
--- a/src/redis.c
+++ b/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;
diff --git a/src/redis.h b/src/redis.h
index 2c05b8e69..4ff187fd3 100644
--- a/src/redis.h
+++ b/src/redis.h
@@ -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.