MCPcopy Create free account
hub / github.com/acl-dev/acl / check

Function check

lib_fiber/c/src/common/socketpair.c:46–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44#if defined(HAS_POLL)
45
46static int check(socket_t listener, socket_t client, socket_t result[2])
47{
48 int ret;
49 struct pollfd fds[2];
50
51 while (result[0] == INVALID_SOCKET || result[1] ==INVALID_SOCKET) {
52 int i = 0;
53 if (result[1] == INVALID_SOCKET) {
54 fds[i].fd = listener;
55 fds[i].events = POLLIN;
56 fds[i].revents = 0;
57 i++;
58 }
59
60 if (result[0] == INVALID_SOCKET) {
61 fds[i].fd = client;
62 fds[i].events = POLLOUT;
63 fds[i].revents = 0;
64 }
65
66 if (var_hook_sys_api) {
67 ret = (*sys_poll)(fds, 2, 10000);
68 } else {
69 ret = WSAPoll(fds, 2, 10000);
70 }
71
72 if (ret < 0) {
73 if (acl_fiber_last_error() == FIBER_EINTR) {
74 continue;
75 }
76 msg_error("WSAPoll error: %s", last_serror());
77 return -1;
78 } else if (ret == 0) {
79 msg_error("WSAPoll timeout: %s", last_serror());
80 return -1;
81 }
82
83 if ((fds[0].revents & POLLIN)) {
84 result[1] = accept(listener, NULL, 0);
85 }
86 if ((fds[1].revents & POLLOUT)) {
87 result[0] = client;
88 }
89 }
90
91 return 0;
92}
93
94#else
95

Callers 1

sane_socketpairFunction · 0.70

Calls 6

WSAPollFunction · 0.85
acl_fiber_last_errorFunction · 0.85
msg_errorFunction · 0.70
last_serrorFunction · 0.70
acceptFunction · 0.50
selectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…