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

Function check

lib_acl/src/stdlib/sys/acl_sane_socketpair.c:60–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58# if defined(ACL_HAS_POLL)
59
60static int check(ACL_SOCKET listener, ACL_SOCKET client, ACL_SOCKET result[2])
61{
62 int ret;
63 struct pollfd fds[2];
64
65 while (result[0] == ACL_SOCKET_INVALID || result[1] ==ACL_SOCKET_INVALID) {
66 int i = 0;
67 if (result[1] == ACL_SOCKET_INVALID) {
68 fds[i].fd = listener;
69 fds[i].events = POLLIN;
70 fds[i].revents = 0;
71 i++;
72 }
73
74 if (result[0] == ACL_SOCKET_INVALID) {
75 fds[i].fd = client;
76 fds[i].events = POLLOUT;
77 fds[i].revents = 0;
78 }
79
80 ret = WSAPoll(fds, 2, 10000);
81 if (ret < 0) {
82 if (acl_last_error() == ACL_EINTR) {
83 continue;
84 }
85 acl_msg_error("WSAPoll error: %s", acl_last_serror());
86 return -1;
87 } else if (ret == 0) {
88 acl_msg_error("WSAPoll timeout: %s", acl_last_serror());
89 return -1;
90 }
91
92 if ((fds[0].revents & POLLIN)) {
93 result[1] = accept(listener, NULL, 0);
94 }
95 if ((fds[1].revents & POLLOUT)) {
96 result[0] = client;
97 }
98 }
99
100 return 0;
101}
102
103# else
104

Callers 1

acl_sane_socketpairFunction · 0.70

Calls 6

WSAPollFunction · 0.85
acl_last_errorFunction · 0.85
acl_msg_errorFunction · 0.85
acl_last_serrorFunction · 0.85
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…