Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
8090c37f
Commit
8090c37f
authored
Jun 28, 2013
by
antirez
Browse files
CONFIG SET maxclients.
parent
75dc48f0
Changes
3
Show whitespace changes
Inline
Side-by-side
src/config.c
View file @
8090c37f
...
...
@@ -541,10 +541,35 @@ void configSetCommand(redisClient *c) {
}
freeMemoryIfNeeded
();
}
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"maxclients"
))
{
int
orig_value
=
server
.
maxclients
;
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
/* Try to check if the OS is capable of supporting so many FDs. */
server
.
maxclients
=
ll
;
if
(
ll
>
orig_value
)
{
adjustOpenFilesLimit
();
if
(
server
.
maxclients
!=
ll
)
{
addReplyErrorFormat
(
c
,
"The operating system is not able to handle the specified number of clients, try with %d"
,
server
.
maxclients
);
server
.
maxclients
=
orig_value
;
return
;
}
if
(
aeGetSetSize
(
server
.
el
)
<
server
.
maxclients
+
REDIS_EVENTLOOP_FDSET_INCR
)
{
if
(
aeResizeSetSize
(
server
.
el
,
server
.
maxclients
+
REDIS_EVENTLOOP_FDSET_INCR
)
==
AE_ERR
)
{
addReplyError
(
c
,
"The event loop API used by Redis is not able to handle the specified number of clients"
);
server
.
maxclients
=
orig_value
;
return
;
}
}
}
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"hz"
))
{
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
server
.
hz
=
(
int
)
ll
;
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
server
.
hz
=
ll
;
if
(
server
.
hz
<
REDIS_MIN_HZ
)
server
.
hz
=
REDIS_MIN_HZ
;
if
(
server
.
hz
>
REDIS_MAX_HZ
)
server
.
hz
=
REDIS_MAX_HZ
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"maxmemory-policy"
))
{
...
...
src/redis.c
View file @
8090c37f
...
...
@@ -1382,7 +1382,7 @@ void initServer() {
createSharedObjects
();
adjustOpenFilesLimit
();
server
.
el
=
aeCreateEventLoop
(
server
.
maxclients
+
1024
);
server
.
el
=
aeCreateEventLoop
(
server
.
maxclients
+
REDIS_EVENTLOOP_FDSET_INCR
);
server
.
db
=
zmalloc
(
sizeof
(
redisDb
)
*
server
.
dbnum
);
if
(
server
.
port
!=
0
)
{
...
...
src/redis.h
View file @
8090c37f
...
...
@@ -129,6 +129,10 @@
#define REDIS_MBULK_BIG_ARG (1024*32)
#define REDIS_LONGSTR_SIZE 21
/* Bytes needed for long -> str */
#define REDIS_AOF_AUTOSYNC_BYTES (1024*1024*32)
/* fdatasync every 32MB */
/* When configuring the Redis eventloop, we setup it so that the total number
* of file descriptors we can handle are server.maxclients + FDSET_INCR
* that is our safety margin. */
#define REDIS_EVENTLOOP_FDSET_INCR 128
/* Hash table parameters */
#define REDIS_HT_MINFILL 10
/* Minimal hash table fill 10% */
...
...
@@ -1072,6 +1076,7 @@ int htNeedsResize(dict *dict);
void
oom
(
const
char
*
msg
);
void
populateCommandTable
(
void
);
void
resetCommandTableStats
(
void
);
void
adjustOpenFilesLimit
(
void
);
/* Set data type */
robj
*
setTypeCreate
(
robj
*
value
);
...
...
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