Commit 7b85f6c5 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Store errno to a variable temporarly

parent 21cbf417
......@@ -287,11 +287,13 @@ void drop_privileges()
{
if(getuid() == 0 && get_config()->uid != 0) {
if(setgid(get_config()->gid) != 0) {
LOG(FATAL) << "Could not change gid: " << strerror(errno);
auto error = errno;
LOG(FATAL) << "Could not change gid: " << strerror(error);
exit(EXIT_FAILURE);
}
if(setuid(get_config()->uid) != 0) {
LOG(FATAL) << "Could not change uid: " << strerror(errno);
auto error = errno;
LOG(FATAL) << "Could not change uid: " << strerror(error);
exit(EXIT_FAILURE);
}
if(setuid(0) != -1) {
......@@ -527,7 +529,8 @@ int event_loop()
auto listener_handler = new ListenHandler(evbase, sv_ssl_ctx, cl_ssl_ctx);
if(get_config()->daemon) {
if(daemon(0, 0) == -1) {
LOG(FATAL) << "Failed to daemonize: " << strerror(errno);
auto error = errno;
LOG(FATAL) << "Failed to daemonize: " << strerror(error);
exit(EXIT_FAILURE);
}
}
......
......@@ -196,7 +196,8 @@ int Http2Session::init_notification()
rv = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0,
sockpair);
if(rv == -1) {
SSLOG(FATAL, this) << "socketpair() failed: errno=" << errno;
auto error = errno;
SSLOG(FATAL, this) << "socketpair() failed: errno=" << error;
return -1;
}
......@@ -277,8 +278,9 @@ void eventcb(bufferevent *bev, short events, void *ptr)
int val = 1;
if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast<char*>(&val), sizeof(val)) == -1) {
auto error = errno;
SSLOG(WARNING, http2session)
<< "Setting option TCP_NODELAY failed: errno=" << errno;
<< "Setting option TCP_NODELAY failed: errno=" << error;
}
return;
}
......
......@@ -106,7 +106,8 @@ void ListenHandler::create_worker_thread(size_t num)
rv = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0,
info->sv);
if(rv == -1) {
LLOG(ERROR, this) << "socketpair() failed: errno=" << errno;
auto error = errno;
LLOG(ERROR, this) << "socketpair() failed: errno=" << error;
continue;
}
......
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