MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / HTTPReceive

Method HTTPReceive

src/network/core/http_winhttp.cpp:303–346  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

301}
302
303/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
304{
305 /* Process all callbacks. */
306 {
307 std::lock_guard<std::mutex> lock(_http_callback_mutex);
308
309 {
310 std::lock_guard<std::mutex> lock(_new_http_callback_mutex);
311 if (!_new_http_callbacks.empty()) {
312 /* We delay adding new callbacks, as HandleQueue() below might add a new callback. */
313 _http_callbacks.insert(_http_callbacks.end(), _new_http_callbacks.begin(), _new_http_callbacks.end());
314 _new_http_callbacks.clear();
315 }
316 }
317
318 for (auto &callback : _http_callbacks) {
319 callback->HandleQueue();
320 }
321 }
322
323 /* Process all requests. */
324 {
325 std::lock_guard<std::mutex> lock(_new_http_requests_mutex);
326 if (!_new_http_requests.empty()) {
327 /* We delay adding new requests, as Receive() below can cause a callback which adds a new requests. */
328 _http_requests.insert(_http_requests.end(), _new_http_requests.begin(), _new_http_requests.end());
329 _new_http_requests.clear();
330 }
331 }
332
333 if (_http_requests.empty()) return;
334
335 for (auto it = _http_requests.begin(); it != _http_requests.end(); /* nothing */) {
336 NetworkHTTPRequest *cur = *it;
337
338 if (cur->Receive()) {
339 it = _http_requests.erase(it);
340 delete cur;
341 continue;
342 }
343
344 ++it;
345 }
346}
347
348void NetworkHTTPInitialize()
349{

Callers

nothing calls this directly

Calls 8

HandleQueueMethod · 0.80
emptyMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
clearMethod · 0.45
ReceiveMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected