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
2e75d394
Commit
2e75d394
authored
Jul 09, 2013
by
antirez
Browse files
IPv6: bind IPv4 and IPv6 interfaces by default.
parent
b5423b09
Changes
2
Show whitespace changes
Inline
Side-by-side
src/anet.c
View file @
2e75d394
...
@@ -392,7 +392,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af)
...
@@ -392,7 +392,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af)
if
((
s
=
socket
(
p
->
ai_family
,
p
->
ai_socktype
,
p
->
ai_protocol
))
==
-
1
)
if
((
s
=
socket
(
p
->
ai_family
,
p
->
ai_socktype
,
p
->
ai_protocol
))
==
-
1
)
continue
;
continue
;
if
(
AF_INET6
==
af
&&
anetV6Only
(
err
,
s
)
==
ANET_ERR
)
if
(
af
==
AF_INET6
&&
anetV6Only
(
err
,
s
)
==
ANET_ERR
)
goto
error
;
/* could continue here? */
goto
error
;
/* could continue here? */
if
(
anetListen
(
err
,
s
,
p
->
ai_addr
,
p
->
ai_addrlen
)
==
ANET_ERR
)
if
(
anetListen
(
err
,
s
,
p
->
ai_addr
,
p
->
ai_addrlen
)
==
ANET_ERR
)
...
...
src/redis.c
View file @
2e75d394
...
@@ -1391,7 +1391,18 @@ void initServer() {
...
@@ -1391,7 +1391,18 @@ void initServer() {
* entering the loop if j == 0. */
* entering the loop if j == 0. */
if (server.bindaddr_count == 0) server.bindaddr[0] = NULL;
if (server.bindaddr_count == 0) server.bindaddr[0] = NULL;
for (j = 0; j < server.bindaddr_count || j == 0; j++) {
for (j = 0; j < server.bindaddr_count || j == 0; j++) {
if (server.bindaddr[j] == NULL) {
/* Bind * for both IPv6 and IPv4. */
server.ipfd[0] = anetTcp6Server(server.neterr,server.port,NULL);
if (server.ipfd[0] != ANET_ERR) server.ipfd_count++;
server.ipfd[1] = anetTcpServer(server.neterr,server.port,NULL);
} else if (strchr(server.bindaddr[j],':')) {
/* Bind IPv6 address. */
server.ipfd[server.ipfd_count] = anetTcp6Server(server.neterr,server.port,server.bindaddr[j]);
} else {
/* Bind IPv4 address. */
server.ipfd[server.ipfd_count] = anetTcpServer(server.neterr,server.port,server.bindaddr[j]);
server.ipfd[server.ipfd_count] = anetTcpServer(server.neterr,server.port,server.bindaddr[j]);
}
if (server.ipfd[server.ipfd_count] == ANET_ERR) {
if (server.ipfd[server.ipfd_count] == ANET_ERR) {
redisLog(REDIS_WARNING,
redisLog(REDIS_WARNING,
"Creating Server TCP listening socket %s:%d: %s",
"Creating Server TCP listening socket %s:%d: %s",
...
...
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