mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 19:24:46 +00:00
Merge pull request #3663 from GregorR/netplay-return-of-cloexec
Making all Netplay sockets should be cloexec
This commit is contained in:
commit
2c0d8e8280
@ -826,6 +826,12 @@ static int init_tcp_connection(const struct addrinfo *res,
|
||||
bool ret = true;
|
||||
int fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
#if defined(IPPROTO_TCP) && defined(TCP_NODELAY)
|
||||
{
|
||||
int flag = 1;
|
||||
@ -834,11 +840,11 @@ static int init_tcp_connection(const struct addrinfo *res,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
#if defined(F_SETFD) && defined(FD_CLOEXEC)
|
||||
/* Don't let any inherited processes keep open our port */
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
|
||||
RARCH_WARN("Cannot set Netplay port to close-on-exec. It may fail to reopen if the client disconnects.\n");
|
||||
#endif
|
||||
|
||||
if (server)
|
||||
{
|
||||
@ -856,13 +862,6 @@ static int init_tcp_connection(const struct addrinfo *res,
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
#if defined(F_SETFD) && defined(FD_CLOEXEC)
|
||||
/* Don't let any inherited processes keep open our port */
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
|
||||
RARCH_WARN("Cannot set Netplay port to close-on-exec. It may fail to reopen if the client disconnects.\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -120,6 +120,12 @@ static bool netplay_net_pre_frame(netplay_t *netplay)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(F_SETFD) && defined(FD_CLOEXEC)
|
||||
/* Don't let any inherited processes keep open our port */
|
||||
if (fcntl(netplay->fd, F_SETFD, FD_CLOEXEC) < 0)
|
||||
RARCH_WARN("Cannot set Netplay port to close-on-exec. It may fail to reopen if the client disconnects.\n");
|
||||
#endif
|
||||
|
||||
/* Connection header */
|
||||
if (netplay_get_info(netplay))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user