Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c184f36d
Commit
c184f36d
authored
May 13, 2013
by
antirez
Browse files
CONFIG REWRITE: support for client-output-buffer-limit.
parent
d95592b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
c184f36d
...
@@ -47,6 +47,12 @@ static struct {
...
@@ -47,6 +47,12 @@ static struct {
{
NULL
,
0
}
{
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
* Config file parsing
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
...
@@ -1336,23 +1342,59 @@ void rewriteConfigDirOption(struct rewriteConfigState *state) {
...
@@ -1336,23 +1342,59 @@ void rewriteConfigDirOption(struct rewriteConfigState *state) {
}
}
void
rewriteConfigSlaveofOption
(
struct
rewriteConfigState
*
state
)
{
void
rewriteConfigSlaveofOption
(
struct
rewriteConfigState
*
state
)
{
char
*
option
=
"slaveof"
;
sds
line
;
sds
line
;
/* If this is a master, we want all the slaveof config options
/* If this is a master, we want all the slaveof config options
* in the file to be removed. */
* in the file to be removed. */
if
(
server
.
masterhost
==
NULL
)
return
;
if
(
server
.
masterhost
==
NULL
)
return
;
line
=
sdscatprintf
(
sdsempty
(),
"s
laveof
%s %d"
,
line
=
sdscatprintf
(
sdsempty
(),
"
%
s %s %d"
,
option
,
server
.
masterhost
,
server
.
masterport
);
server
.
masterhost
,
server
.
masterport
);
rewriteConfigRewriteLine
(
state
,
"slaveof"
,
line
,
1
);
rewriteConfigRewriteLine
(
state
,
option
,
line
,
1
);
}
}
void
rewriteConfigAppendonlyOption
(
struct
rewriteConfigState
*
state
)
{
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
)
{
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
)
{
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
)
{
sds
rewriteConfigGetContentFromState
(
struct
rewriteConfigState
*
state
)
{
...
...
src/redis.c
View file @
c184f36d
...
@@ -1198,6 +1198,8 @@ void createSharedObjects(void) {
...
@@ -1198,6 +1198,8 @@ void createSharedObjects(void) {
}
}
void
initServerConfig
()
{
void
initServerConfig
()
{
int
j
;
getRandomHexChars
(
server
.
runid
,
REDIS_RUN_ID_SIZE
);
getRandomHexChars
(
server
.
runid
,
REDIS_RUN_ID_SIZE
);
server
.
configfile
=
NULL
;
server
.
configfile
=
NULL
;
server
.
hz
=
REDIS_DEFAULT_HZ
;
server
.
hz
=
REDIS_DEFAULT_HZ
;
...
@@ -1303,15 +1305,8 @@ void initServerConfig() {
...
@@ -1303,15 +1305,8 @@ void initServerConfig() {
server
.
repl_no_slaves_since
=
time
(
NULL
);
server
.
repl_no_slaves_since
=
time
(
NULL
);
/* Client output buffer limits */
/* Client output buffer limits */
server
.
client_obuf_limits
[
REDIS_CLIENT_LIMIT_CLASS_NORMAL
].
hard_limit_bytes
=
0
;
for
(
j
=
0
;
j
<
REDIS_CLIENT_LIMIT_NUM_CLASSES
;
j
++
)
server
.
client_obuf_limits
[
REDIS_CLIENT_LIMIT_CLASS_NORMAL
].
soft_limit_bytes
=
0
;
server
.
client_obuf_limits
[
j
]
=
clientBufferLimitsDefaults
[
j
];
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
;
/* Double constants initialization */
/* Double constants initialization */
R_Zero
=
0
.
0
;
R_Zero
=
0
.
0
;
...
...
src/redis.h
View file @
c184f36d
...
@@ -493,6 +493,8 @@ typedef struct clientBufferLimitsConfig {
...
@@ -493,6 +493,8 @@ typedef struct clientBufferLimitsConfig {
time_t
soft_limit_seconds
;
time_t
soft_limit_seconds
;
}
clientBufferLimitsConfig
;
}
clientBufferLimitsConfig
;
extern
clientBufferLimitsConfig
clientBufferLimitsDefaults
[
REDIS_CLIENT_LIMIT_NUM_CLASSES
];
/* The redisOp structure defines a Redis Operation, that is an instance of
/* The redisOp structure defines a Redis Operation, that is an instance of
* a command with an argument vector, database ID, propagation target
* a command with an argument vector, database ID, propagation target
* (REDIS_PROPAGATE_*), and command pointer.
* (REDIS_PROPAGATE_*), and command pointer.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment