nghttpx: Failing to listen on server socket is fatal error

This commit is contained in:
Tatsuhiro Tsujikawa 2017-03-26 11:04:45 +09:00
parent 696a7ce407
commit 7dc39b1ee9
1 changed files with 11 additions and 13 deletions

View File

@ -626,7 +626,7 @@ int create_unix_domain_server_socket(UpstreamAddr &faddr,
auto fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); auto fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (fd == -1) { if (fd == -1) {
auto error = errno; auto error = errno;
LOG(WARN) << "socket() syscall failed: " LOG(FATAL) << "socket() syscall failed: "
<< xsi_strerror(error, errbuf.data(), errbuf.size()); << xsi_strerror(error, errbuf.data(), errbuf.size());
return -1; return -1;
} }
@ -634,7 +634,7 @@ int create_unix_domain_server_socket(UpstreamAddr &faddr,
auto fd = socket(AF_UNIX, SOCK_STREAM, 0); auto fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) { if (fd == -1) {
auto error = errno; auto error = errno;
LOG(WARN) << "socket() syscall failed: " LOG(FATAL) << "socket() syscall failed: "
<< xsi_strerror(error, errbuf.data(), errbuf.size()); << xsi_strerror(error, errbuf.data(), errbuf.size());
return -1; return -1;
} }
@ -644,7 +644,7 @@ int create_unix_domain_server_socket(UpstreamAddr &faddr,
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val,
static_cast<socklen_t>(sizeof(val))) == -1) { static_cast<socklen_t>(sizeof(val))) == -1) {
auto error = errno; auto error = errno;
LOG(WARN) << "Failed to set SO_REUSEADDR option to listener socket: " LOG(FATAL) << "Failed to set SO_REUSEADDR option to listener socket: "
<< xsi_strerror(error, errbuf.data(), errbuf.size()); << xsi_strerror(error, errbuf.data(), errbuf.size());
close(fd); close(fd);
return -1; return -1;
@ -716,11 +716,9 @@ int create_tcp_server_socket(UpstreamAddr &faddr,
addrinfo *res, *rp; addrinfo *res, *rp;
rv = getaddrinfo(node, service.c_str(), &hints, &res); rv = getaddrinfo(node, service.c_str(), &hints, &res);
if (rv != 0) { if (rv != 0) {
if (LOG_ENABLED(INFO)) { LOG(FATAL) << "Unable to get IPv" << (faddr.family == AF_INET ? "4" : "6")
LOG(INFO) << "Unable to get IPv" << (faddr.family == AF_INET ? "4" : "6")
<< " address for " << faddr.host << ", port " << faddr.port << " address for " << faddr.host << ", port " << faddr.port
<< ": " << gai_strerror(rv); << ": " << gai_strerror(rv);
}
return -1; return -1;
} }
@ -836,7 +834,7 @@ int create_tcp_server_socket(UpstreamAddr &faddr,
} }
if (!rp) { if (!rp) {
LOG(WARN) << "Listening " << (faddr.family == AF_INET ? "IPv4" : "IPv6") LOG(FATAL) << "Listening " << (faddr.family == AF_INET ? "IPv4" : "IPv6")
<< " socket failed"; << " socket failed";
return -1; return -1;