MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / LockedPollRequests

Method LockedPollRequests

common/HTTPDownloader.cpp:78–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
79{
80 if (m_pending_http_requests.empty())
81 return;
82
83 InternalPollRequests();
84
85 const Common::Timer::Value current_time = Common::Timer::GetCurrentValue();
86 u32 active_requests = 0;
87 u32 unstarted_requests = 0;
88
89 for (size_t index = 0; index < m_pending_http_requests.size();)
90 {
91 Request* req = m_pending_http_requests[index];
92 if (req->state == Request::State::Pending)
93 {
94 unstarted_requests++;
95 index++;
96 continue;
97 }
98
99 if ((req->state == Request::State::Started || req->state == Request::State::Receiving) &&
100 current_time >= req->start_time && Common::Timer::ConvertValueToSeconds(current_time - req->start_time) >= m_timeout)
101 {
102 // request timed out
103 Console.Error("Request for '%s' timed out", req->url.c_str());
104
105 req->state.store(Request::State::Cancelled);
106 m_pending_http_requests.erase(m_pending_http_requests.begin() + index);
107 lock.unlock();
108
109 req->callback(HTTP_STATUS_TIMEOUT, std::string(), Request::Data());
110
111 CloseRequest(req);
112
113 lock.lock();
114 continue;
115 }
116 else if ((req->state == Request::State::Started || req->state == Request::State::Receiving) && req->progress &&
117 req->progress->IsCancelled())
118 {
119 // request timed out
120 Console.Error("Request for '%s' cancelled", req->url.c_str());
121
122 req->state.store(Request::State::Cancelled);
123 m_pending_http_requests.erase(m_pending_http_requests.begin() + index);
124 lock.unlock();
125
126 req->callback(HTTP_STATUS_CANCELLED, std::string(), Request::Data());
127
128 CloseRequest(req);
129
130 lock.lock();
131 continue;
132 }
133
134 if (req->state != Request::State::Complete)
135 {

Callers

nothing calls this directly

Calls 14

unlockMethod · 0.80
stringClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
ErrorMethod · 0.45
c_strMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
callbackMethod · 0.45
lockMethod · 0.45
IsCancelledMethod · 0.45
SetProgressRangeMethod · 0.45

Tested by

no test coverage detected