{
wrapper_pthread_arg_t* pth = (wrapper_pthread_arg_t*) arg;
frsh_thread_id_t* thread_id = pth->thread_id;
+ void *thread_arg = pth->pthread_arg;
+ frsh_thread_code_t pthread_code = pth->pthread_code;
+ int errcode;
*thread_id = fosa_thread_self();
/* bind this thread to vres */
- pth->errcode = frsh_thread_bind(pth->vres, *thread_id);
-
- sem_post(pth->stopper);
- if (pth->errcode) /* vres binding was not successful */
+ errcode = frsh_thread_bind(pth->vres, *thread_id);
+ pth->errcode = errcode;
+
+ sem_post(pth->stopper);
+ /* No access to pth is allowed after this point, it can vanish already */
+
+ if (errcode) /* vres binding was not successful */
return NULL;
/* execute thread function */
- return pth->pthread_code(pth->pthread_arg);
+ return pthread_code(thread_arg);
}
/*