Unverified Commit df5f543b authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
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.
parent e1d98bca
...@@ -3053,14 +3053,15 @@ int listenToPort(int port, socketFds *sfd) { ...@@ -3053,14 +3053,15 @@ int listenToPort(int port, socketFds *sfd) {
sfd->fd[sfd->count] = anetTcpServer(server.neterr,port,addr,server.tcp_backlog); sfd->fd[sfd->count] = anetTcpServer(server.neterr,port,addr,server.tcp_backlog);
} }
if (sfd->fd[sfd->count] == ANET_ERR) { if (sfd->fd[sfd->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",
addr, port, server.neterr); addr, port, server.neterr);
if (errno == EADDRNOTAVAIL && optional) if (net_errno == EADDRNOTAVAIL && optional)
continue; continue;
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || if (net_errno == ENOPROTOOPT || net_errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || net_errno == ESOCKTNOSUPPORT || net_errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT) net_errno == EAFNOSUPPORT)
continue; continue;
/* Rollback successful listens before exiting */ /* Rollback successful listens before exiting */
......
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