plugged a bunch of handle leaks !
This commit is contained in:
parent
08f8caf924
commit
58a1f0c68e
@ -22,6 +22,8 @@ extern char* fake_heap_end;
|
|||||||
static void initArgv();
|
static void initArgv();
|
||||||
static u32 heapBase;
|
static u32 heapBase;
|
||||||
|
|
||||||
|
void __destroy_handle_list(void);
|
||||||
|
|
||||||
void __attribute__((noreturn)) __ctru_exit(int rc)
|
void __attribute__((noreturn)) __ctru_exit(int rc)
|
||||||
{
|
{
|
||||||
// Run the global destructors
|
// Run the global destructors
|
||||||
@ -35,6 +37,9 @@ void __attribute__((noreturn)) __ctru_exit(int rc)
|
|||||||
// Unmap the application heap
|
// Unmap the application heap
|
||||||
svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0);
|
svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0);
|
||||||
|
|
||||||
|
// Close some handles
|
||||||
|
__destroy_handle_list();
|
||||||
|
|
||||||
// Jump to the loader if it provided a callback
|
// Jump to the loader if it provided a callback
|
||||||
if (__system_retAddr)
|
if (__system_retAddr)
|
||||||
__system_retAddr();
|
__system_retAddr();
|
||||||
|
@ -360,7 +360,7 @@ void aptExit()
|
|||||||
svcCloseHandle(aptSleepSync);
|
svcCloseHandle(aptSleepSync);
|
||||||
|
|
||||||
svcCloseHandle(aptStatusMutex);
|
svcCloseHandle(aptStatusMutex);
|
||||||
//svcCloseHandle(aptLockHandle);
|
svcCloseHandle(aptLockHandle);
|
||||||
svcCloseHandle(aptStatusEvent);
|
svcCloseHandle(aptStatusEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +788,10 @@ FSFILE_Close(Handle handle)
|
|||||||
if((ret = svcSendSyncRequest(handle)))
|
if((ret = svcSendSyncRequest(handle)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return cmdbuf[1];
|
ret = cmdbuf[1];
|
||||||
|
if(!ret)ret = svcCloseHandle(handle);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Read data from an open file
|
/*! Read data from an open file
|
||||||
|
@ -59,6 +59,7 @@ void gspExitEventHandler()
|
|||||||
// Stop event thread
|
// Stop event thread
|
||||||
gspRunEvents = false;
|
gspRunEvents = false;
|
||||||
svcWaitSynchronization(gspEventThread, 1000000000);
|
svcWaitSynchronization(gspEventThread, 1000000000);
|
||||||
|
svcCloseHandle(gspEventThread);
|
||||||
|
|
||||||
// Free events
|
// Free events
|
||||||
int i;
|
int i;
|
||||||
|
@ -48,6 +48,7 @@ cleanup1:
|
|||||||
void hidExit()
|
void hidExit()
|
||||||
{
|
{
|
||||||
// Unmap HID sharedmem and close handles.
|
// Unmap HID sharedmem and close handles.
|
||||||
|
int i; for(i=0; i<5; i++)svcCloseHandle(hidEvents[i]);
|
||||||
svcUnmapMemoryBlock(hidMemHandle, (u32)hidSharedMem);
|
svcUnmapMemoryBlock(hidMemHandle, (u32)hidSharedMem);
|
||||||
svcCloseHandle(hidMemHandle);
|
svcCloseHandle(hidMemHandle);
|
||||||
svcCloseHandle(hidHandle);
|
svcCloseHandle(hidHandle);
|
||||||
|
@ -45,6 +45,7 @@ cleanup1:
|
|||||||
void irrstExit()
|
void irrstExit()
|
||||||
{
|
{
|
||||||
irrstUsed = false;
|
irrstUsed = false;
|
||||||
|
svcCloseHandle(irrstEvent);
|
||||||
// Unmap ir:rst sharedmem and close handles.
|
// Unmap ir:rst sharedmem and close handles.
|
||||||
svcUnmapMemoryBlock(irrstMemHandle, (u32)irrstSharedMem);
|
svcUnmapMemoryBlock(irrstMemHandle, (u32)irrstSharedMem);
|
||||||
svcCloseHandle(irrstMemHandle);
|
svcCloseHandle(irrstMemHandle);
|
||||||
|
@ -58,6 +58,18 @@ Handle __get_handle_from_list(const char* name) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __destroy_handle_list(void) {
|
||||||
|
if((u32)__service_ptr == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
u32 i, num = __service_ptr->num;
|
||||||
|
|
||||||
|
for(i=0; i<num; i++)
|
||||||
|
svcCloseHandle(__service_ptr->services[i].handle);
|
||||||
|
|
||||||
|
__service_ptr->num = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Result srvInit()
|
Result srvInit()
|
||||||
{
|
{
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
@ -163,4 +175,4 @@ Result srvUnregisterProcess(u32 procid)
|
|||||||
if((rc = svcSendSyncRequest(g_srv_handle))) return rc;
|
if((rc = svcSendSyncRequest(g_srv_handle))) return rc;
|
||||||
|
|
||||||
return cmdbuf[1];
|
return cmdbuf[1];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user