Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Close handle on thread release
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Dec 12, 2017
1 parent f1870ec commit aeca2c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pthread/phal.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

int phal_thread_create(phal_tid *tid, void (*start_routine)(void*), void *arg);
void phal_thread_exit(phal_tid *tid);

// Called after the thread exited, to free up any potential resources
int phal_thread_destroy(phal_tid *tid);
void **phal_get_tls();

int phal_semaphore_create(phal_semaphore *sem);
Expand Down
3 changes: 3 additions & 0 deletions pthread/rthread_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ _rthread_reaper(void)
// TODO: stack and tib
//_rthread_free_stack(thread->stack);
//_dl_free_tib(thread->tib, sizeof(*thread));
int res = phal_thread_destroy(&thread->tib_tid);
if (res)
_rthread_debug(3, "Failed to free tid %d: %d", &thread->tib_tid, res);
} else {
/* initial thread isn't part of TIB allocation */
_rthread_debug(3, "rthread reaping %p (initial)\n",
Expand Down
4 changes: 4 additions & 0 deletions pthread/sys/switch/phal.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ void phal_thread_exit(phal_tid *tid) {
svcExitThread();
}

int phal_thread_destroy(phal_tid *tid) {
return svcCloseHandle(*tid);
}

int phal_thread_sleep(uint64_t msec) {
u64 nanos = msec * 1000 * 1000;
return svcSleepThread(nanos);
Expand Down

0 comments on commit aeca2c3

Please sign in to comment.