Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
285add55
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
285add55
编写于
5月 25, 2009
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
maxclients implemented, see redis.conf for details
上级
a0f643ea
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
28 addition
and
1 deletion
+28
-1
redis.c
redis.c
+18
-1
redis.conf
redis.conf
+10
-0
未找到文件。
redis.c
浏览文件 @
285add55
...
...
@@ -245,6 +245,7 @@ struct redisServer {
int
masterport
;
redisClient
*
master
;
/* client that is master for this slave */
int
replstate
;
unsigned
int
maxclients
;
/* Sort parameters - qsort_r() is only available under BSD so we
* have to take this state global, in order to pass it to sortCompare() */
int
sort_desc
;
...
...
@@ -862,6 +863,7 @@ static void initServerConfig() {
server
.
dbfilename
=
"dump.rdb"
;
server
.
requirepass
=
NULL
;
server
.
shareobjects
=
0
;
server
.
maxclients
=
0
;
ResetServerSaveParams
();
appendServerSaveParams
(
60
*
60
,
1
);
/* save after 1 hour and 1 change */
...
...
@@ -1020,6 +1022,8 @@ static void loadServerConfig(char *filename) {
if
(
server
.
dbnum
<
1
)
{
err
=
"Invalid number of databases"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"maxclients"
)
&&
argc
==
2
)
{
server
.
maxclients
=
atoi
(
argv
[
1
]);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"slaveof"
)
&&
argc
==
3
)
{
server
.
masterhost
=
sdsnew
(
argv
[
1
]);
server
.
masterport
=
atoi
(
argv
[
2
]);
...
...
@@ -1500,6 +1504,7 @@ static void addReplySds(redisClient *c, sds s) {
static
void
acceptHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
int
cport
,
cfd
;
char
cip
[
128
];
redisClient
*
c
;
REDIS_NOTUSED
(
el
);
REDIS_NOTUSED
(
mask
);
REDIS_NOTUSED
(
privdata
);
...
...
@@ -1510,11 +1515,23 @@ static void acceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
return
;
}
redisLog
(
REDIS_DEBUG
,
"Accepted %s:%d"
,
cip
,
cport
);
if
(
createClient
(
cfd
)
==
NULL
)
{
if
(
(
c
=
createClient
(
cfd
)
)
==
NULL
)
{
redisLog
(
REDIS_WARNING
,
"Error allocating resoures for the client"
);
close
(
cfd
);
/* May be already closed, just ingore errors */
return
;
}
/* If maxclient directive is set and this is one client more... close the
* connection. Note that we create the client instead to check before
* for this condition, since now the socket is already set in nonblocking
* mode and we can send an error for free using the Kernel I/O */
if
(
server
.
maxclients
&&
listLength
(
server
.
clients
)
>
server
.
maxclients
)
{
char
*
err
=
"-ERR max number of clients reached
\r\n
"
;
/* That's a best effort error message, don't check write errors */
write
(
c
->
fd
,
err
,
strlen
(
err
));
freeClient
(
c
);
return
;
}
server
.
stat_numconnections
++
;
}
...
...
redis.conf
浏览文件 @
285add55
...
...
@@ -78,6 +78,16 @@ databases 16
# requirepass foobared
################################### LIMITS ####################################
# Set the max number of connected clients at the same time. By default there
# is no limit, and it's up to the number of file descriptors the Redis process
# is able to open. The special value '0' means no limts.
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
# maxclients 128
############################### ADVANCED CONFIG ###############################
# Glue small output buffers together in order to send small replies in a
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录