wesnothd: Properly enable cloexec even on non-keepalive codepath

This commit is contained in:
loonycyborg 2022-03-24 13:47:43 +03:00
parent ada186769b
commit 63c72ea42b
No known key found for this signature in database
GPG key ID: 6E8233FAB8F26D61

View file

@ -136,7 +136,6 @@ void server_base::serve(boost::asio::yield_context yield, boost::asio::ip::tcp::
setsockopt(socket->native_handle(), SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout));
setsockopt(socket->native_handle(), SOL_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));
setsockopt(socket->native_handle(), SOL_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
fcntl(socket->native_handle(), F_SETFD, FD_CLOEXEC);
#endif
#if defined(__APPLE__) && defined(__MACH__)
setsockopt(socket->native_handle(), IPPROTO_TCP, TCP_KEEPALIVE, &timeout, sizeof(timeout));
@ -144,6 +143,10 @@ void server_base::serve(boost::asio::yield_context yield, boost::asio::ip::tcp::
}
#endif
#ifdef __linux__
fcntl(socket->native_handle(), F_SETFD, FD_CLOEXEC);
#endif
DBG_SERVER << client_address(socket) << "\tnew connection tentatively accepted\n";
uint32_t protocol_version;