MCPcopy Create free account
hub / github.com/defold/defold / socket_waitfd

Function socket_waitfd

engine/script/src/luasocket/usocket.c:23–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21#define WAITFD_W POLLOUT
22#define WAITFD_C (POLLIN|POLLOUT)
23int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
24 int ret;
25 struct pollfd pfd;
26 pfd.fd = *ps;
27 pfd.events = sw;
28 pfd.revents = 0;
29 if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
30 do {
31 int t = (int)(timeout_getretry(tm)*1e3);
32 ret = poll(&pfd, 1, t >= 0? t: -1);
33 } while (ret == -1 && errno == EINTR);
34 if (ret == -1) return errno;
35 if (ret == 0) return IO_TIMEOUT;
36 if (sw == WAITFD_C && (pfd.revents & (POLLIN|POLLERR))) return IO_CLOSED;
37 return IO_DONE;
38}
39#else
40
41#define WAITFD_R 1

Callers 8

socket_connectFunction · 0.70
socket_acceptFunction · 0.70
socket_sendFunction · 0.70
socket_sendtoFunction · 0.70
socket_recvFunction · 0.70
socket_recvfromFunction · 0.70
socket_writeFunction · 0.70
socket_readFunction · 0.70

Calls 2

timeout_getretryFunction · 0.85
selectFunction · 0.50

Tested by

no test coverage detected