]> Chaos Git - corbenik/ctrulib.git/commitdiff
Finally added code to exit httpc properly via HTTPC_Finalize.
authoryellows8 <yellows8@users.noreply.github.com>
Tue, 8 Mar 2016 20:00:57 +0000 (15:00 -0500)
committeryellows8 <yellows8@users.noreply.github.com>
Tue, 8 Mar 2016 20:00:57 +0000 (15:00 -0500)
libctru/include/3ds/services/httpc.h
libctru/source/services/httpc.c

index 6e23bc1e35b63d69686fff929b6ba1358b390c76..a0009fdf140292c6faa754cdc54dddbc8a8cb3fd 100644 (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.
index db020b0106f7e5c8be49b182d48dac8d625d1cbc..25e1ff14c5efd2394a6a164d4787b6e2c3d956f8 100644 (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();