MCPcopy Create free account
hub / github.com/Tencent/phxsql / RoutineReadWithTimeout

Function RoutineReadWithTimeout

phxsqlproxy/routineutil.cpp:63–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63int RoutineReadWithTimeout(int source_fd, char * buf, int buf_size, int timeout_ms) {
64 assert(IsNonBlock(source_fd));
65 struct pollfd pf[1];
66 int nfds = 0;
67 memset(pf, 0, sizeof(pf));
68 pf[0].fd = source_fd;
69 pf[0].events = (POLLIN | POLLERR | POLLHUP);
70 nfds++;
71
72 int return_fd_count = co_poll(co_get_epoll_ct(), pf, nfds, timeout_ms);
73 if (return_fd_count < 0) {
74 return return_fd_count;
75 }
76
77 if (pf[0].revents & POLLIN) {
78 return read(source_fd, buf, buf_size);
79 } else if (pf[0].revents & POLLHUP) {
80 return return_fd_count;
81 } else if (pf[0].revents & POLLERR) {
82 return return_fd_count;
83 }
84 return return_fd_count;
85}
86
87int RoutineWriteWithTimeout(int dest_fd, const char * buf, int write_size, int timeout_ms) {
88 assert(IsNonBlock(dest_fd));

Callers 1

runMethod · 0.85

Calls 1

IsNonBlockFunction · 0.85

Tested by

no test coverage detected