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
498dc555
Commit
498dc555
authored
Jan 17, 2012
by
antirez
Browse files
Introduced three client limit classes: normal, slave, pubsub
parent
3853c168
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
498dc555
...
@@ -1149,3 +1149,18 @@ unsigned long getClientOutputBufferMemoryUsage(redisClient *c) {
...
@@ -1149,3 +1149,18 @@ unsigned long getClientOutputBufferMemoryUsage(redisClient *c) {
return
c
->
reply_bytes
+
(
list_item_size
*
listLength
(
c
->
reply
));
return
c
->
reply_bytes
+
(
list_item_size
*
listLength
(
c
->
reply
));
}
}
/* Get the class of a client, used in order to envorce limits to different
* classes of clients.
*
* The function will return one of the following:
* REDIS_CLIENT_LIMIT_CLASS_NORMAL -> Normal client
* REDIS_CLIENT_LIMIT_CLASS_SLAVE -> Slave or client executing MONITOR command
* REDIS_CLIENT_LIMIT_CLASS_PUBSUB -> Client subscribed to Pub/Sub channels
*/
int
getClientLimitClass
(
redisClient
*
c
)
{
if
(
c
->
flags
&
REDIS_SLAVE
)
return
REDIS_CLIENT_LIMIT_CLASS_SLAVE
;
if
(
dictSize
(
c
->
pubsub_channels
)
||
listLength
(
c
->
pubsub_patterns
))
return
REDIS_CLIENT_LIMIT_CLASS_PUBSUB
;
return
REDIS_CLIENT_LIMIT_CLASS_NORMAL
;
}
src/redis.h
View file @
498dc555
...
@@ -146,6 +146,12 @@
...
@@ -146,6 +146,12 @@
#define REDIS_REQ_INLINE 1
#define REDIS_REQ_INLINE 1
#define REDIS_REQ_MULTIBULK 2
#define REDIS_REQ_MULTIBULK 2
/* Client classes for client limits, currently used only for
* the max-client-output-buffer limit implementation. */
#define REDIS_CLIENT_LIMIT_CLASS_NORMAL 0
#define REDIS_CLIENT_LIMIT_CLASS_SLAVE 1
#define REDIS_CLIENT_LIMIT_CLASS_PUBSUB 2
/* Slave replication state - slave side */
/* Slave replication state - slave side */
#define REDIS_REPL_NONE 0
/* No active replication */
#define REDIS_REPL_NONE 0
/* No active replication */
#define REDIS_REPL_CONNECT 1
/* Must connect to master */
#define REDIS_REPL_CONNECT 1
/* Must connect to master */
...
...
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