citra-emu
/
citra
Archived
1
0
Fork 0

Services/HTTP: Stubbed the CloseContext service function.

It is currently unknown how the real http module handles trying to close contexts for requests that are already in flight.
This commit is contained in:
Subv 2018-07-21 20:11:20 -05:00
parent 34baa882c8
commit 799b45233f
2 changed files with 34 additions and 1 deletions

View File

@ -164,11 +164,35 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
rb.PushMappedBuffer(buffer); rb.PushMappedBuffer(buffer);
} }
void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x3, 2, 0);
u32 context_handle = rp.Pop<u32>();
LOG_WARNING(Service_HTTP, "(STUBBED) called, handle={}", context_handle);
auto itr = contexts.find(context_handle);
if (itr == contexts.end()) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_CONTEXT_ERROR);
LOG_ERROR(Service_HTTP, "called, context {} not found", context_handle);
return;
}
// TODO(Subv): What happens if you try to close a context that's currently being used?
ASSERT(itr->second.state == RequestState::NotStarted);
contexts.erase(itr);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
}
HTTP_C::HTTP_C() : ServiceFramework("http:C", 32) { HTTP_C::HTTP_C() : ServiceFramework("http:C", 32) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0x00010044, &HTTP_C::Initialize, "Initialize"}, {0x00010044, &HTTP_C::Initialize, "Initialize"},
{0x00020082, &HTTP_C::CreateContext, "CreateContext"}, {0x00020082, &HTTP_C::CreateContext, "CreateContext"},
{0x00030040, nullptr, "CloseContext"}, {0x00030040, &HTTP_C::CloseContext, "CloseContext"},
{0x00040040, nullptr, "CancelConnection"}, {0x00040040, nullptr, "CancelConnection"},
{0x00050040, nullptr, "GetRequestState"}, {0x00050040, nullptr, "GetRequestState"},
{0x00060040, nullptr, "GetDownloadSizeState"}, {0x00060040, nullptr, "GetDownloadSizeState"},

View File

@ -45,6 +45,15 @@ private:
*/ */
void CreateContext(Kernel::HLERequestContext& ctx); void CreateContext(Kernel::HLERequestContext& ctx);
/**
* HTTP_C::CreateContext service function
* Inputs:
* 1 : Context handle
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void CloseContext(Kernel::HLERequestContext& ctx);
Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr; Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr;
std::unordered_map<u32, Context> contexts; std::unordered_map<u32, Context> contexts;