mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 08:41:21 +00:00
Client types generalized.
Because of output buffer limits Redis internals had this idea of type of clients: normal, pubsub, slave. It is possible to set different output buffer limits for the three kinds of clients. However all the macros and API were named after output buffer limit classes, while the idea of a client type is a generic one that can be reused. This commit does two things: 1) Rename the API and defines with more general names. 2) Change the class of clients executing the MONITOR command from "slave" to "normal". "2" is a good idea because you want to have very special settings for slaves, that are not a good idea for MONITOR clients that are instead normal clients even if they are conceptually slave-alike (since it is a push protocol). The backward-compatibility breakage resulting from "2" is considered to be minimal to care, since MONITOR is a debugging command, and because anyway this change is not going to break the format or the behavior, but just when a connection is closed on big output buffer issues.
This commit is contained in:
18
src/config.c
18
src/config.c
@ -49,7 +49,7 @@ static struct {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
clientBufferLimitsConfig clientBufferLimitsDefaults[REDIS_CLIENT_LIMIT_NUM_CLASSES] = {
|
||||
clientBufferLimitsConfig clientBufferLimitsDefaults[REDIS_CLIENT_TYPE_COUNT] = {
|
||||
{0, 0, 0}, /* normal */
|
||||
{1024*1024*256, 1024*1024*64, 60}, /* slave */
|
||||
{1024*1024*32, 1024*1024*8, 60} /* pubsub */
|
||||
@ -425,7 +425,7 @@ void loadServerConfigFromString(char *config) {
|
||||
} else if (!strcasecmp(argv[0],"client-output-buffer-limit") &&
|
||||
argc == 5)
|
||||
{
|
||||
int class = getClientLimitClassByName(argv[1]);
|
||||
int class = getClientTypeByName(argv[1]);
|
||||
unsigned long long hard, soft;
|
||||
int soft_seconds;
|
||||
|
||||
@ -777,7 +777,7 @@ void configSetCommand(redisClient *c) {
|
||||
long val;
|
||||
|
||||
if ((j % 4) == 0) {
|
||||
if (getClientLimitClassByName(v[j]) == -1) {
|
||||
if (getClientTypeByName(v[j]) == -1) {
|
||||
sdsfreesplitres(v,vlen);
|
||||
goto badfmt;
|
||||
}
|
||||
@ -795,7 +795,7 @@ void configSetCommand(redisClient *c) {
|
||||
unsigned long long hard, soft;
|
||||
int soft_seconds;
|
||||
|
||||
class = getClientLimitClassByName(v[j]);
|
||||
class = getClientTypeByName(v[j]);
|
||||
hard = strtoll(v[j+1],NULL,10);
|
||||
soft = strtoll(v[j+2],NULL,10);
|
||||
soft_seconds = strtoll(v[j+3],NULL,10);
|
||||
@ -1058,13 +1058,13 @@ void configGetCommand(redisClient *c) {
|
||||
sds buf = sdsempty();
|
||||
int j;
|
||||
|
||||
for (j = 0; j < REDIS_CLIENT_LIMIT_NUM_CLASSES; j++) {
|
||||
for (j = 0; j < REDIS_CLIENT_TYPE_COUNT; j++) {
|
||||
buf = sdscatprintf(buf,"%s %llu %llu %ld",
|
||||
getClientLimitClassName(j),
|
||||
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);
|
||||
if (j != REDIS_CLIENT_LIMIT_NUM_CLASSES-1)
|
||||
if (j != REDIS_CLIENT_TYPE_COUNT-1)
|
||||
buf = sdscatlen(buf," ",1);
|
||||
}
|
||||
addReplyBulkCString(c,"client-output-buffer-limit");
|
||||
@ -1479,7 +1479,7 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state
|
||||
int j;
|
||||
char *option = "client-output-buffer-limit";
|
||||
|
||||
for (j = 0; j < REDIS_CLIENT_LIMIT_NUM_CLASSES; j++) {
|
||||
for (j = 0; j < REDIS_CLIENT_TYPE_COUNT; j++) {
|
||||
int force = (server.client_obuf_limits[j].hard_limit_bytes !=
|
||||
clientBufferLimitsDefaults[j].hard_limit_bytes) ||
|
||||
(server.client_obuf_limits[j].soft_limit_bytes !=
|
||||
@ -1495,7 +1495,7 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state
|
||||
server.client_obuf_limits[j].soft_limit_bytes);
|
||||
|
||||
line = sdscatprintf(sdsempty(),"%s %s %s %s %ld",
|
||||
option, getClientLimitClassName(j), hard, soft,
|
||||
option, getClientTypeName(j), hard, soft,
|
||||
(long) server.client_obuf_limits[j].soft_limit_seconds);
|
||||
rewriteConfigRewriteLine(state,option,line,force);
|
||||
}
|
||||
|
Reference in New Issue
Block a user