mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Merge pull request #1214 from kaoshijuan/unstable
fixed initServer fail problem
This commit is contained in:
commit
038e356dbc
18
src/redis.c
18
src/redis.c
@ -1476,6 +1476,7 @@ void adjustOpenFilesLimit(void) {
|
||||
|
||||
void initServer() {
|
||||
int j;
|
||||
int ip_count;
|
||||
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
@ -1507,10 +1508,19 @@ void initServer() {
|
||||
if (server.bindaddr_count == 0) server.bindaddr[0] = NULL;
|
||||
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);
|
||||
/* Bind * for both IPv6 and IPv4.
|
||||
* Should consider that someone only has IPV6 and someone only get IPV4 */
|
||||
ip_count = 0;
|
||||
server.ipfd[ip_count] = anetTcp6Server(server.neterr,server.port,NULL);
|
||||
if (server.ipfd[ip_count] != ANET_ERR) ip_count++;
|
||||
|
||||
server.ipfd[ip_count] = anetTcpServer(server.neterr,server.port,NULL);
|
||||
if(server.ipfd[ip_count] != ANET_ERR ) ip_count++;
|
||||
|
||||
/* It should be ip_count plus one
|
||||
* because out of this branch, the server.ipfd_count would increase */
|
||||
server.ipfd_count += (ip_count - 1);
|
||||
|
||||
} else if (strchr(server.bindaddr[j],':')) {
|
||||
/* Bind IPv6 address. */
|
||||
server.ipfd[server.ipfd_count] = anetTcp6Server(server.neterr,server.port,server.bindaddr[j]);
|
||||
|
Loading…
Reference in New Issue
Block a user