machinarium: try PTHREAD_CANCEL_DISABLE/DEFERRED to avoid __libc calls

This commit is contained in:
Dmitry Simonenko 2018-11-22 18:44:53 +03:00
parent dd3e984431
commit 6b91e6e609
3 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,8 @@ machine_main(void *arg)
mm_machine_t *machine = arg;
mm_self = machine;
mm_thread_disable_cancel();
/* set thread name */
if (machine->name)
mm_thread_set_name(&machine->thread, machine->name);

View File

@ -43,3 +43,10 @@ int mm_thread_set_name(mm_thread_t *thread, char *name)
rc = pthread_setname_np(thread->id, name);
return rc;
}
int mm_thread_disable_cancel(void)
{
int unused;
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &unused);
return pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &unused);
}

View File

@ -21,5 +21,6 @@ struct mm_thread
int mm_thread_create(mm_thread_t*, int, mm_thread_function_t, void*);
int mm_thread_join(mm_thread_t*);
int mm_thread_set_name(mm_thread_t*, char*);
int mm_thread_disable_cancel(void);
#endif /* MM_THREAD_H */