fix(libSceHttp): sceHttpWaitRequest reports no ready requests

It returned the network error, which titles that poll their epoll treat
as fatal. No request is ever pending, since sending fails at once, so the
wait now times out with no events; an infinite wait throws.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
MathiasDevelopes
2026-10-08 20:05:21 +02:00
parent 4ddbf0497d
commit 485eb1aedd
3 changed files with 14 additions and 5 deletions
+6 -5
View File
@@ -4,9 +4,11 @@
#include "prx/libc/include/General.hpp"
#include "prx/libSceHttp/src/HttpErrors.hpp"
#include <atomic>
#include <chrono>
#include <limits>
#include <stdexcept>
#include <string_view>
#include <thread>
// 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) {
+7
View File
@@ -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];
+1
View File
@@ -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