Finally added code to exit httpc properly via HTTPC_Finalize.

This commit is contained in:
yellows8 2016-03-08 15:00:57 -05:00
parent e2852d14f1
commit 049d2e2373
2 changed files with 21 additions and 0 deletions

View File

@ -139,6 +139,12 @@ Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downl
*/
Result HTTPC_Initialize(Handle handle, u32 sharedmem_size, Handle sharedmem_handle);
/**
* @brief Finalizes HTTPC.
* @param handle HTTPC service handle to use.
*/
Result HTTPC_Finalize(Handle handle);
/**
* @brief Initializes a HTTP connection session.
* @param handle HTTPC service handle to use.

View File

@ -61,6 +61,9 @@ Result httpcInit(u32 sharedmem_size)
void httpcExit(void)
{
if (AtomicDecrement(&__httpc_refcount)) return;
HTTPC_Finalize(__httpc_servhandle);
svcCloseHandle(__httpc_servhandle);
if(__httpc_sharedmem_handle)
@ -207,6 +210,18 @@ Result HTTPC_Initialize(Handle handle, u32 sharedmem_size, Handle sharedmem_hand
return cmdbuf[1];
}
Result HTTPC_Finalize(Handle handle)
{
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=IPC_MakeHeader(0x39,0,0); // 0x390000
Result ret=0;
if(R_FAILED(ret=svcSendSyncRequest(handle)))return ret;
return cmdbuf[1];
}
Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle)
{
u32* cmdbuf=getThreadCommandBuffer();