mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-17 08:20:30 +02:00
Remove sleeps and timed polling from networking
Socket waits now block in select() on the socket plus a wake or cancel socket (Common/Net/Cancel), so a stop or cancel ends them at once. - HTTP: cancel flags become net::CancelToken; Connect waits once on all addresses, receives wait instead of spinning, no DNS retry sleep. - Adhoc: the friend finder and adhoc server block on their sockets with a wake socket and a deadline; matching runs on a CoreTiming tick instead of two threads (savestate section bumped). - sceNetInet select/poll check without blocking and park the HLE thread, re-checked from a CoreTiming event until ready or the emulated timeout. - Vendor the aemu_postoffice client (was a submodule) with no sleeps: waits on the socket, close via shutdown and an eventcount, cancelable connects, and lock-free session slot claims. - PortManager waits without a timeout; PSP_InitWait replaces the headless boot poll. - TimeUtil: sleep_us/sleep_ms only outside the core; sleep_precise, sleep_random, yield and the Windows timer period are gone. - Unit test for the socket waits.
This commit is contained in:
1 parent
9f13f0f051
commit
5f0f72bfda
58 files changed
+3822
-763
No files matched your search
@@ -92,7 +92,6 @@ HTTPRequest::HTTPRequest(int connectionID, int method, const char *url, u64 cont
|
||||
this->url = url ? url : "";
|
||||
this->contentLength = contentLength;
|
||||
|
||||
//progress_.cancelled = &cancelled_;
|
||||
responseContent_.clear();
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ int HTTPRequest::getResponseContentLength() {
|
||||
}
|
||||
|
||||
int HTTPRequest::abortRequest() {
|
||||
cancelled_ = true;
|
||||
cancel_.Cancel();
|
||||
// FIXME: Will sceHttpAbortRequest returns an error if the request was not sent yet?
|
||||
//if (progress_.progress == 0.0f)
|
||||
// return SCE_HTTP_ERROR_BEFORE_SEND;
|
||||
@@ -238,11 +237,11 @@ int HTTPRequest::sendRequest(u32 postDataPtr, u32 postDataSize) {
|
||||
}
|
||||
|
||||
// Establish Connection
|
||||
if (!client.Connect(getResolveRetryCount(), getConnectTimeout() / 1000000.0, &cancelled_)) {
|
||||
if (!client.Connect(getResolveRetryCount(), getConnectTimeout() / 1000000.0, &cancel_)) {
|
||||
ERROR_LOG(Log::sceNet, "Failed connecting to server or cancelled.");
|
||||
return -1; // SCE_HTTP_ERROR_ABORTED
|
||||
}
|
||||
if (cancelled_) {
|
||||
if (cancel_.IsCancelled()) {
|
||||
return SCE_HTTP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
@@ -259,13 +258,13 @@ int HTTPRequest::sendRequest(u32 postDataPtr, u32 postDataSize) {
|
||||
break;
|
||||
}
|
||||
net::Buffer buffer_;
|
||||
net::RequestProgress progress_(&cancelled_);
|
||||
net::RequestProgress progress_(&cancel_);
|
||||
http::RequestParams req(fileUrl.Resource(), "*/*");
|
||||
const char* postData = Memory::GetCharPointer(postDataPtr);
|
||||
if (postDataSize > 0)
|
||||
NotifyMemInfo(MemBlockFlags::READ, postDataPtr, postDataSize, "HttpSendRequest");
|
||||
int err = client.SendRequestWithData(methodstr.c_str(), req, std::string(postData ? postData : "", postData ? postDataSize : 0), extraHeaders.c_str(), &progress_);
|
||||
if (cancelled_) {
|
||||
if (cancel_.IsCancelled()) {
|
||||
return SCE_HTTP_ERROR_ABORTED;
|
||||
}
|
||||
if (err < 0) {
|
||||
@@ -274,7 +273,7 @@ int HTTPRequest::sendRequest(u32 postDataPtr, u32 postDataSize) {
|
||||
|
||||
// Retrieve Response's Status Code (and Headers too?)
|
||||
responseCode_ = client.ReadResponseHeaders(&buffer_, responseHeaders_, &progress_, &httpLine_);
|
||||
if (cancelled_) {
|
||||
if (cancel_.IsCancelled()) {
|
||||
return SCE_HTTP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
@@ -285,7 +284,7 @@ int HTTPRequest::sendRequest(u32 postDataPtr, u32 postDataSize) {
|
||||
ERROR_LOG(Log::sceNet, "Unable to read HTTP response entity: %d", res);
|
||||
}
|
||||
entity_.TakeAll(&responseContent_);
|
||||
if (cancelled_) {
|
||||
if (cancel_.IsCancelled()) {
|
||||
return SCE_HTTP_ERROR_ABORTED;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user