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

Function acl_write_wait_ms

lib_acl/src/stdlib/iostuff/acl_write_wait.c:41–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41int acl_write_wait_ms(ACL_SOCKET fd, int timeout)
42{
43 const char *myname = "acl_write_wait";
44 struct pollfd fds;
45 int delay = timeout;
46#if 0
47 time_t begin, end;
48#endif
49
50 fds.events = POLLOUT;
51 fds.revents = 0;
52 fds.fd = fd;
53
54#if 0
55 begin = time(NULL);
56#endif
57
58 for (;;) {
59 switch (__sys_poll(&fds, 1, delay)) {
60#ifdef ACL_WINDOWS
61 case SOCKET_ERROR:
62#else
63 case -1:
64#endif
65 if (acl_last_error() == ACL_EINTR) {
66 continue;
67 }
68#if 0
69 acl_msg_error("%s(%d), %s: poll error(%s), fd: %d",
70 __FILE__, __LINE__, myname,
71 acl_last_serror(), (int) fd);
72#endif
73 return -1;
74 case 0:
75 if (timeout == 0) {
76 acl_set_error(ACL_EAGAIN);
77 } else {
78 acl_set_error(ACL_ETIMEDOUT);
79 }
80#if 0
81 end = time(NULL);
82 acl_msg_error("%s(%d), %s: poll return 0, delay=%d, "
83 "fd=%d, cost=%ld", __FILE__, __LINE__,
84 myname, delay, fd, (long) ( end - begin));
85#endif
86 return -1;
87 default:
88 if (fds.revents & POLLNVAL) {
89 acl_msg_error("%s(%d), %s: %s, POLLNVAL, fd=%d",
90 __FILE__, __LINE__, myname,
91 acl_last_serror(), (int) fd);
92 acl_set_error(ACL_EINVAL);
93 return -1;
94 }
95
96 if ((fds.revents & (POLLHUP | POLLERR))) {
97 /*
98 acl_msg_error("%s(%d), %s: %s, %s, %s, fd=%d",

Callers 4

acl_write_waitFunction · 0.85
acl_sys_socket.cFile · 0.85
acl_timed_connect_ms2Function · 0.85
write_waitMethod · 0.85

Calls 5

acl_last_errorFunction · 0.85
acl_msg_errorFunction · 0.85
acl_last_serrorFunction · 0.85
acl_set_errorFunction · 0.85
acl_msg_warnFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…