MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / pollRecv

Function pollRecv

3ds/source/server.cpp:121–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119 static const int POLL_SLICE_MS = 1000;
120
121 static ssize_t pollRecv(s32 sock, char* buf, size_t len, int& idleMs, bool trackCancel)
122 {
123 while (true) {
124 if (trackCancel && TransferStatus::cancelRequested()) {
125 return -1;
126 }
127 struct pollfd pfd;
128 pfd.fd = sock;
129 pfd.events = POLLIN;
130 pfd.revents = 0;
131 int ready = poll(&pfd, 1, POLL_SLICE_MS);
132 if (ready < 0) {
133 return -1;
134 }
135 if (ready == 0) {
136 idleMs += POLL_SLICE_MS;
137 if (idleMs >= RECV_TIMEOUT_MS) {
138 return 0;
139 }
140 continue;
141 }
142 idleMs = 0;
143 return recv(sock, buf, len, 0);
144 }
145 }
146
147 static void sendResponse(s32 clientSocket, const Server::HttpResponse& response)
148 {

Callers 2

streamBodyToFileFunction · 0.70
handleHttpRequestFunction · 0.70

Calls 1

cancelRequestedFunction · 0.70

Tested by

no test coverage detected