mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Making all Netplay sockets should be cloexec
All Netplay sockets should close-on-exec. There is no reason for xdg-screensaver to keep Netplay sockets alive.
This commit is contained in:
parent
6826ec7748
commit
bd354cd275
@ -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…
x
Reference in New Issue
Block a user