mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-07-02 15:56:02 +00:00
vita: Replace select to poll
now newlib support [this][1] [1]: https://github.com/vitasdk/newlib/pull/70
This commit is contained in:
parent
cfe75eb569
commit
4a4a23c7c4
@ -82,7 +82,7 @@ int setNonFatalRecvTimeoutMs(SOCKET s, int timeoutMs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pollSockets(struct pollfd* pollFds, int pollFdsCount, int timeoutMs) {
|
int pollSockets(struct pollfd* pollFds, int pollFdsCount, int timeoutMs) {
|
||||||
#if defined(LC_WINDOWS) || defined(__vita__)
|
#if defined(LC_WINDOWS)
|
||||||
// We could have used WSAPoll() but it has some nasty bugs
|
// We could have used WSAPoll() but it has some nasty bugs
|
||||||
// https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
|
// https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
|
||||||
//
|
//
|
||||||
@ -107,19 +107,10 @@ int pollSockets(struct pollfd* pollFds, int pollFdsCount, int timeoutMs) {
|
|||||||
if (pollFds[i].events & POLLOUT) {
|
if (pollFds[i].events & POLLOUT) {
|
||||||
FD_SET(pollFds[i].fd, &writeFds);
|
FD_SET(pollFds[i].fd, &writeFds);
|
||||||
|
|
||||||
#ifdef LC_WINDOWS
|
|
||||||
// Windows signals failed connections as an exception,
|
// Windows signals failed connections as an exception,
|
||||||
// while Linux signals them as writeable.
|
// while Linux signals them as writeable.
|
||||||
FD_SET(pollFds[i].fd, &exceptFds);
|
FD_SET(pollFds[i].fd, &exceptFds);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LC_WINDOWS
|
|
||||||
// nfds is unused on Windows
|
|
||||||
if (pollFds[i].fd >= nfds) {
|
|
||||||
nfds = pollFds[i].fd + 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tv.tv_sec = timeoutMs / 1000;
|
tv.tv_sec = timeoutMs / 1000;
|
||||||
|
@ -53,24 +53,7 @@ typedef int SOCKADDR_LEN;
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#if defined(__vita__)
|
|
||||||
#define POLLIN 0x0001
|
|
||||||
#define POLLPRI 0x0002
|
|
||||||
#define POLLOUT 0x0004
|
|
||||||
#define POLLERR 0x0008
|
|
||||||
#define POLLRDNORM 0x0040
|
|
||||||
#define POLLWRNORM POLLOUT
|
|
||||||
#define POLLRDBAND 0x0080
|
|
||||||
#define POLLWRBAND 0x0100
|
|
||||||
|
|
||||||
struct pollfd {
|
|
||||||
int fd;
|
|
||||||
short events;
|
|
||||||
short revents;
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ioctlsocket ioctl
|
#define ioctlsocket ioctl
|
||||||
#define LastSocketError() errno
|
#define LastSocketError() errno
|
||||||
|
Loading…
x
Reference in New Issue
Block a user