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

Function RoutinePeekWithTimeout

phxsqlproxy/routineutil.cpp:133–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133int RoutinePeekWithTimeout(int source_fd, char * buf, int buf_size, int timeout_ms) {
134 assert(IsNonBlock(source_fd));
135 struct pollfd pf[1];
136 int nfds = 0;
137 memset(pf, 0, sizeof(pf));
138 pf[0].fd = source_fd;
139 pf[0].events = (POLLIN | POLLERR | POLLHUP);
140 nfds++;
141
142 int return_fd_count = co_poll(co_get_epoll_ct(), pf, nfds, timeout_ms);
143 if (return_fd_count < 0) {
144 return return_fd_count;
145 }
146
147 if (pf[0].revents & POLLIN) {
148 return recv(source_fd, buf, buf_size, MSG_PEEK);
149 } else if (pf[0].revents & POLLHUP) {
150 return return_fd_count;
151 } else if (pf[0].revents & POLLERR) {
152 return return_fd_count;
153 }
154 return return_fd_count;
155}
156
157}

Callers 1

ProcessProxyHeaderMethod · 0.85

Calls 1

IsNonBlockFunction · 0.85

Tested by

no test coverage detected