Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
6dabd34a
R
redis
项目概览
hanoi2005
/
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,发现更多精彩内容 >>
提交
6dabd34a
编写于
7月 04, 2013
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ability to bind multiple addresses.
上级
14857dec
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
8 deletion
+43
-8
src/config.c
src/config.c
+37
-4
src/redis.c
src/redis.c
+3
-3
src/redis.h
src/redis.h
+3
-1
未找到文件。
src/config.c
浏览文件 @
6dabd34a
...
...
@@ -125,8 +125,15 @@ void loadServerConfigFromString(char *config) {
if
(
server
.
port
<
0
||
server
.
port
>
65535
)
{
err
=
"Invalid port"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"bind"
)
&&
argc
==
2
)
{
server
.
bindaddr
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"bind"
)
&&
argc
>=
2
)
{
int
j
,
addresses
=
argc
-
1
;
if
(
addresses
>
REDIS_BINDADDR_MAX
)
{
err
=
"Too many bind addresses specified"
;
goto
loaderr
;
}
for
(
j
=
0
;
j
<
addresses
;
j
++
)
server
.
bindaddr
[
j
]
=
zstrdup
(
argv
[
j
+
1
]);
server
.
bindaddr_count
=
addresses
;
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"unixsocket"
)
&&
argc
==
2
)
{
server
.
unixsocket
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"unixsocketperm"
)
&&
argc
==
2
)
{
...
...
@@ -895,7 +902,6 @@ void configGetCommand(redisClient *c) {
config_get_string_field
(
"dbfilename"
,
server
.
rdb_filename
);
config_get_string_field
(
"requirepass"
,
server
.
requirepass
);
config_get_string_field
(
"masterauth"
,
server
.
masterauth
);
config_get_string_field
(
"bind"
,
server
.
bindaddr
);
config_get_string_field
(
"unixsocket"
,
server
.
unixsocket
);
config_get_string_field
(
"logfile"
,
server
.
logfile
);
config_get_string_field
(
"pidfile"
,
server
.
pidfile
);
...
...
@@ -1081,6 +1087,14 @@ void configGetCommand(redisClient *c) {
decrRefCount
(
flagsobj
);
matches
++
;
}
if
(
stringmatch
(
pattern
,
"bind"
,
0
))
{
sds
aux
=
sdsjoin
(
server
.
bindaddr
,
server
.
bindaddr_count
,
" "
);
addReplyBulkCString
(
c
,
"bind"
);
addReplyBulkCString
(
c
,
aux
);
sdsfree
(
aux
);
matches
++
;
}
setDeferredMultiBulkLength
(
c
,
replylen
,
matches
*
2
);
}
...
...
@@ -1472,6 +1486,25 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state
}
}
/* Rewrite the bind option. */
void
rewriteConfigBindOption
(
struct
rewriteConfigState
*
state
)
{
int
force
=
1
;
sds
line
,
addresses
;
char
*
option
=
"bind"
;
/* Nothing to rewrite if we don't have bind addresses. */
if
(
server
.
bindaddr_count
==
0
)
return
;
/* Rewrite as bind <addr1> <addr2> ... <addrN> */
addresses
=
sdsjoin
(
server
.
bindaddr
,
server
.
bindaddr_count
,
" "
);
line
=
sdsnew
(
option
);
line
=
sdscatlen
(
line
,
" "
,
1
);
line
=
sdscatsds
(
line
,
addresses
);
sdsfree
(
addresses
);
rewriteConfigRewriteLine
(
state
,
option
,
line
,
force
);
}
/* Glue together the configuration lines in the current configuration
* rewrite state into a single string, stripping multiple empty lines. */
sds
rewriteConfigGetContentFromState
(
struct
rewriteConfigState
*
state
)
{
...
...
@@ -1607,7 +1640,7 @@ int rewriteConfig(char *path) {
rewriteConfigYesNoOption
(
state
,
"daemonize"
,
server
.
daemonize
,
0
);
rewriteConfigStringOption
(
state
,
"pidfile"
,
server
.
pidfile
,
REDIS_DEFAULT_PID_FILE
);
rewriteConfigNumericalOption
(
state
,
"port"
,
server
.
port
,
REDIS_SERVERPORT
);
rewriteConfig
StringOption
(
state
,
"bind"
,
server
.
bindaddr
,
NULL
);
rewriteConfig
BindOption
(
state
);
rewriteConfigStringOption
(
state
,
"unixsocket"
,
server
.
unixsocket
,
NULL
);
rewriteConfigOctalOption
(
state
,
"unixsocketperm"
,
server
.
unixsocketperm
,
REDIS_DEFAULT_UNIX_SOCKET_PERM
);
rewriteConfigNumericalOption
(
state
,
"timeout"
,
server
.
maxidletime
,
REDIS_MAXIDLETIME
);
...
...
src/redis.c
浏览文件 @
6dabd34a
...
...
@@ -1185,7 +1185,7 @@ void initServerConfig() {
server
.
runid
[
REDIS_RUN_ID_SIZE
]
=
'\0'
;
server
.
arch_bits
=
(
sizeof
(
long
)
==
8
)
?
64
:
32
;
server
.
port
=
REDIS_SERVERPORT
;
server
.
bindaddr
=
NULL
;
server
.
bindaddr
_count
=
0
;
server
.
unixsocket
=
NULL
;
server
.
unixsocketperm
=
REDIS_DEFAULT_UNIX_SOCKET_PERM
;
server
.
ipfd
=
-
1
;
...
...
@@ -1386,7 +1386,7 @@ void initServer() {
server
.
db
=
zmalloc
(
sizeof
(
redisDb
)
*
server
.
dbnum
);
if
(
server
.
port
!=
0
)
{
server
.
ipfd
=
anetTcpServer
(
server
.
neterr
,
server
.
port
,
server
.
bindaddr
);
server
.
ipfd
=
anetTcpServer
(
server
.
neterr
,
server
.
port
,
server
.
bindaddr
,
server
.
bindaddr_count
);
if
(
server
.
ipfd
==
ANET_ERR
)
{
redisLog
(
REDIS_WARNING
,
"Opening port %d: %s"
,
server
.
port
,
server
.
neterr
);
...
...
@@ -2754,7 +2754,7 @@ void redisSetProcTitle(char *title) {
#ifdef USE_SETPROCTITLE
setproctitle
(
"%s %s:%d"
,
title
,
server
.
bindaddr
?
server
.
bindaddr
:
"*"
,
server
.
bindaddr
_count
?
server
.
bindaddr
[
0
]
:
"*"
,
server
.
port
);
#else
REDIS_NOTUSED
(
title
);
...
...
src/redis.h
浏览文件 @
6dabd34a
...
...
@@ -120,6 +120,7 @@
#define REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC 1
#define REDIS_DEFAULT_MIN_SLAVES_TO_WRITE 0
#define REDIS_DEFAULT_MIN_SLAVES_MAX_LAG 10
#define REDIS_BINDADDR_MAX 16
/* Protocol and I/O related defines */
#define REDIS_MAX_QUERYBUF_LEN (1024*1024*1024)
/* 1GB max query buffer. */
...
...
@@ -576,7 +577,8 @@ struct redisServer {
int
sentinel_mode
;
/* True if this instance is a Sentinel. */
/* Networking */
int
port
;
/* TCP listening port */
char
*
bindaddr
;
/* Bind address or NULL */
char
*
bindaddr
[
REDIS_BINDADDR_MAX
];
/* Addresses we should bind to */
int
bindaddr_count
;
/* Number of addresses in server.bindaddr[] */
char
*
unixsocket
;
/* UNIX socket path */
mode_t
unixsocketperm
;
/* UNIX socket permission */
int
ipfd
;
/* TCP socket file descriptor */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录