diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 54a10157..81238769 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -193,15 +193,13 @@ int Http2Session::init_notification() { int rv; int sockpair[2]; - rv = socketpair(AF_UNIX, SOCK_STREAM, 0, sockpair); + rv = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0, + sockpair); if(rv == -1) { SSLOG(FATAL, this) << "socketpair() failed: errno=" << errno; return -1; } - for(int i = 0; i < 2; ++i) { - evutil_make_socket_nonblocking(sockpair[i]); - evutil_make_socket_closeonexec(sockpair[i]); - } + wrbev_ = bufferevent_socket_new(evbase_, sockpair[0], BEV_OPT_CLOSE_ON_FREE| BEV_OPT_DEFER_CALLBACKS); diff --git a/src/shrpx_listen_handler.cc b/src/shrpx_listen_handler.cc index 4ce67eee..21eef4d3 100644 --- a/src/shrpx_listen_handler.cc +++ b/src/shrpx_listen_handler.cc @@ -103,17 +103,13 @@ void ListenHandler::create_worker_thread(size_t num) for(size_t i = 0; i < num; ++i) { int rv; auto info = util::make_unique(); - rv = socketpair(AF_UNIX, SOCK_STREAM, 0, info->sv); + rv = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0, + info->sv); if(rv == -1) { LLOG(ERROR, this) << "socketpair() failed: errno=" << errno; continue; } - for(int j = 0; j < 2; ++j) { - evutil_make_socket_nonblocking(info->sv[j]); - evutil_make_socket_closeonexec(info->sv[j]); - } - info->sv_ssl_ctx = sv_ssl_ctx_; info->cl_ssl_ctx = cl_ssl_ctx_;