(Netplay) Create wrapper function for select()
This commit is contained in:
parent
cec500ece5
commit
f6d0a80b3d
|
@ -336,7 +336,7 @@ static void network_cmd_poll(rarch_cmd_t *handle)
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(handle->net_fd, &fds);
|
FD_SET(handle->net_fd, &fds);
|
||||||
|
|
||||||
if (select(handle->net_fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0)
|
if (socket_select(handle->net_fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!FD_ISSET(handle->net_fd, &fds))
|
if (!FD_ISSET(handle->net_fd, &fds))
|
||||||
|
|
|
@ -348,7 +348,7 @@ static int poll_input(netplay_t *netplay, bool block)
|
||||||
FD_SET(netplay->udp_fd, &fds);
|
FD_SET(netplay->udp_fd, &fds);
|
||||||
FD_SET(netplay->fd, &fds);
|
FD_SET(netplay->fd, &fds);
|
||||||
|
|
||||||
if (select(max_fd, &fds, NULL, NULL, &tmp_tv) < 0)
|
if (socket_select(max_fd, &fds, NULL, NULL, &tmp_tv) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Somewhat hacky,
|
/* Somewhat hacky,
|
||||||
|
@ -1485,7 +1485,7 @@ static void netplay_pre_frame_spectate(netplay_t *netplay)
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(netplay->fd, &fds);
|
FD_SET(netplay->fd, &fds);
|
||||||
|
|
||||||
if (select(netplay->fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0)
|
if (socket_select(netplay->fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!FD_ISSET(netplay->fd, &fds))
|
if (!FD_ISSET(netplay->fd, &fds))
|
||||||
|
|
|
@ -110,3 +110,13 @@ int socket_close(int fd)
|
||||||
return close(fd);
|
return close(fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int socket_select(int nfds, fd_set *readfs, fd_set *writefds,
|
||||||
|
fd_set *errorfds, struct timeval *timeout)
|
||||||
|
{
|
||||||
|
#if defined(__CELLOS_LV2__)
|
||||||
|
return socketselect(nfds, readfs, writefds, errorfds, timeout);
|
||||||
|
#else
|
||||||
|
return select(nfds, readfs, writefds, errorfds, timeout);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -81,9 +81,6 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__)
|
|
||||||
#define select(nfds, readfds, writefds, errorfds, timeout) socketselect(nfds, readfds, writefds, errorfds, timeout)
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Compatibility layer for legacy or incomplete BSD socket implementations.
|
/* Compatibility layer for legacy or incomplete BSD socket implementations.
|
||||||
|
@ -125,5 +122,8 @@ bool socket_nonblock(int fd);
|
||||||
|
|
||||||
int socket_close(int fd);
|
int socket_close(int fd);
|
||||||
|
|
||||||
|
int socket_select(int nfds, fd_set *readfs, fd_set *writefds,
|
||||||
|
fd_set *errorfds, struct timeval *timeout);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue