Commit 94694010 authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by Oran Agra
Browse files

Server won't start on alpine/libmusl without IPv6. (#8655)

listenToPort attempts to gracefully handle and ignore certain errors but does not store errno prior to logging, which in turn calls several libc functions that may overwrite errno.

This has been discovered due to libmusl strftime() always returning with errno set to EINVAL, which resulted with docker-library/redis#273.

(cherry picked from commit df5f543b)
parent 1b03a0d7
...@@ -2765,13 +2765,14 @@ int listenToPort(int port, int *fds, int *count) { ...@@ -2765,13 +2765,14 @@ int listenToPort(int port, int *fds, int *count) {
server.tcp_backlog); server.tcp_backlog);
} }
if (fds[*count] == ANET_ERR) { if (fds[*count] == ANET_ERR) {
int net_errno = errno;
serverLog(LL_WARNING, serverLog(LL_WARNING,
"Could not create server TCP listening socket %s:%d: %s", "Could not create server TCP listening socket %s:%d: %s",
server.bindaddr[j] ? server.bindaddr[j] : "*", server.bindaddr[j] ? server.bindaddr[j] : "*",
port, server.neterr); port, server.neterr);
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || if (net_errno == ENOPROTOOPT || net_errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || net_errno == ESOCKTNOSUPPORT || net_errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT || errno == EADDRNOTAVAIL) net_errno == EAFNOSUPPORT || net_errno == EADDRNOTAVAIL)
continue; continue;
return C_ERR; return C_ERR;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment