diff --git a/core/libs/prx/libSceHttp/Export.cpp b/core/libs/prx/libSceHttp/Export.cpp index 10588fdab..c69c6b687 100644 --- a/core/libs/prx/libSceHttp/Export.cpp +++ b/core/libs/prx/libSceHttp/Export.cpp @@ -4,9 +4,11 @@ #include "prx/libc/include/General.hpp" #include "prx/libSceHttp/src/HttpErrors.hpp" #include +#include #include #include #include +#include // No network is emulated: contexts, templates and requests can be created, but any request // that would touch the network fails with the library's network error. @@ -233,11 +235,10 @@ int APS5_VABI sceHttpUnsetEpoll(int id) { } int APS5_VABI sceHttpWaitRequest(HttpEpollHandle eh, HttpNBEvent* nbev, int maxevents, int timeout) { - (void)eh; - (void)nbev; - (void)maxevents; - (void)timeout; - return ERROR_NETWORK; + if (!eh || !nbev || maxevents <= 0) return ERROR_INVALID_VALUE; + if (timeout < 0) NotImplemented_nid_no_patch(__func__); + std::this_thread::sleep_for(std::chrono::microseconds(timeout)); + return 0; } int APS5_VABI sceHttpCreateRequestWithURL(int conn_id, int method, const char* url, uint64_t content_length) { diff --git a/core/libs/tests/GuestHttp.cpp b/core/libs/tests/GuestHttp.cpp index ae6d034d9..2157acf91 100644 --- a/core/libs/tests/GuestHttp.cpp +++ b/core/libs/tests/GuestHttp.cpp @@ -15,6 +15,7 @@ int APS5_VABI sceHttpUriUnescape(char*, std::size_t*, std::size_t, const char*); int APS5_VABI sceHttpUriSweepPath(char*, const char*, std::size_t); int APS5_VABI sceHttpCreateEpoll(int, HttpEpollHandle*); int APS5_VABI sceHttpDestroyEpoll(int, HttpEpollHandle); +int APS5_VABI sceHttpWaitRequest(HttpEpollHandle, HttpNBEvent*, int, int); int APS5_VABI sceHttpReadData(int, void*, std::size_t); int APS5_VABI sceHttpCreateRequest2(int, const char*, const char*, std::uint64_t); int APS5_VABI sceHttpsEnableOption(int, std::uint32_t); @@ -185,6 +186,12 @@ int main() { HttpEpollHandle epoll = nullptr; Require(sceHttpCreateEpoll(1, nullptr) == invalidValue); Require(sceHttpCreateEpoll(1, &epoll) == 0 && epoll != nullptr); + HttpNBEvent events[2]{}; + Require(sceHttpWaitRequest(epoll, events, 2, 0) == 0); + Require(sceHttpWaitRequest(epoll, events, 2, 1000) == 0); + Require(sceHttpWaitRequest(epoll, nullptr, 2, 0) == invalidValue); + Require(sceHttpWaitRequest(epoll, events, 0, 0) == invalidValue); + Require(sceHttpWaitRequest(nullptr, events, 2, 0) == invalidValue); Require(sceHttpDestroyEpoll(1, epoll) == 0); char data[16]; diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 25b90199f..caa01d7b1 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -233,6 +233,7 @@ Throughout the project, every function at every stage either **does exactly what - [sce::Json::InitParameter2](../../core/libs/prx/libSceJson2/Export.cpp) (libSceJson2) - layout inferred, not known: assumed to start with the allocator, its user data and the file buffer size, in that order, and the whole struct is assumed to fit in 40 bytes; `Initializer::initialize(InitParameter2)` ignores them as `initialize(InitParameter)` does - [sceAjmBatchJobSetResampleParameters, sceAjmBatchJobGetResampleInfo](../../core/libs/prx/libSceAjm.native/src/Ajm.cpp) (libSceAjm) - the ratio is taken as decoded samples per output sample and num_samples as the decoded samples the resampler holds, both inferred from FMOD (Hades II); the console's interpolation is unknown, a 4-point Catmull-Rom is used. The flags argument is ignored, as in shadPS4 and Kyty - [scePlayerReviewDialogOpen, scePlayerReviewDialogGetResult](../../core/libs/prx/libSceCdlgPlayerReview/Export.cpp) (libSceCdlgPlayerReview) - the PS5-only dialog has no public reference: the parameter is not read and the result is assumed to start with the 32-bit common dialog result, as `sceWebBrowserDialogGetResult` assumes +- [sceHttpWaitRequest](../../core/libs/prx/libSceHttp/Export.cpp) (libSceHttp) - the timeout is assumed to be in microseconds and a negative timeout to wait without limit; the invalid-value error for a null handle or event array or a non-positive event count is assumed, not measured. No request is ever pending, so the call waits for the timeout and returns 0 events, and a wait without limit throws ### Functional