eina_thread: don't leak on pthread_cancel().

if we cancel a thread we should still free the context, so use the new
EINA_THREAD_CLEANUP_PUSH() and EINA_THREAD_CLEANUP_POP()
This commit is contained in:
Gustavo Sverzut Barbieri 2016-09-16 22:17:25 -03:00
parent a050395770
commit 76c3726ef0
1 changed files with 5 additions and 2 deletions

View File

@ -137,6 +137,8 @@ _eina_internal_call(void *context)
pthread_t self;
#endif
EINA_THREAD_CLEANUP_PUSH(free, c);
if (c->prio == EINA_THREAD_BACKGROUND ||
c->prio == EINA_THREAD_IDLE)
eina_sched_prio_drop();
@ -144,13 +146,14 @@ _eina_internal_call(void *context)
#ifdef EINA_HAVE_DEBUG
self = pthread_self();
_eina_debug_thread_add(&self);
EINA_THREAD_CLEANUP_PUSH(_eina_debug_thread_del, &self);
#endif
r = c->func((void*) c->data, eina_thread_self());
#ifdef EINA_HAVE_DEBUG
_eina_debug_thread_del(&self);
EINA_THREAD_CLEANUP_POP(EINA_TRUE);
#endif
free(c);
EINA_THREAD_CLEANUP_POP(EINA_TRUE);
return r;
}