[Xenomai-git] Philippe Gerum : lib/cobalt: catch unexpected sync errors with thread trampoline
Module: xenomai-forge Branch: master Commit: b483819e7060346a2013751cfb572358399b68ce URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b483819e7060346a2013751cfb572358399b68ce Author: Philippe Gerum r...@xenomai.org Date: Mon Dec 9 12:33:07 2013 +0100 lib/cobalt: catch unexpected sync errors with thread trampoline --- lib/cobalt/thread.c | 23 --- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c index 0063799..89c1d46 100644 --- a/lib/cobalt/thread.c +++ b/lib/cobalt/thread.c @@ -28,6 +28,7 @@ #include asm/xenomai/syscall.h #include current.h #include internal.h +#include boilerplate/ancillaries.h static pthread_attr_ex_t default_attr_ex; @@ -349,15 +350,23 @@ int pthread_create_ex(pthread_t *tid, if (ret) goto fail; - while (__STD(sem_wait(iargs.sync)) errno == EINTR) - ; + for (;;) { + ret = __STD(sem_wait(iargs.sync)); + if (ret errno == EINTR) + continue; + if (ret == 0) { + ret = iargs.ret; + if (ret == 0) + *tid = ltid; + break; + } + ret = -errno; + if (detachstate == PTHREAD_CREATE_JOINABLE) + pthread_join(ltid, NULL); + panic(regular sem_wait() failed with %s, symerror(ret)); + } __cobalt_thread_harden(); /* May fail if regular thread. */ - ret = iargs.ret; - if (ret == 0) - *tid = ltid; - else if (detachstate == PTHREAD_CREATE_JOINABLE) - pthread_join(ltid, NULL); fail: __STD(sem_destroy(iargs.sync)); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/cobalt: catch unexpected sync errors with thread trampoline
Module: xenomai-forge Branch: next Commit: b483819e7060346a2013751cfb572358399b68ce URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b483819e7060346a2013751cfb572358399b68ce Author: Philippe Gerum r...@xenomai.org Date: Mon Dec 9 12:33:07 2013 +0100 lib/cobalt: catch unexpected sync errors with thread trampoline --- lib/cobalt/thread.c | 23 --- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c index 0063799..89c1d46 100644 --- a/lib/cobalt/thread.c +++ b/lib/cobalt/thread.c @@ -28,6 +28,7 @@ #include asm/xenomai/syscall.h #include current.h #include internal.h +#include boilerplate/ancillaries.h static pthread_attr_ex_t default_attr_ex; @@ -349,15 +350,23 @@ int pthread_create_ex(pthread_t *tid, if (ret) goto fail; - while (__STD(sem_wait(iargs.sync)) errno == EINTR) - ; + for (;;) { + ret = __STD(sem_wait(iargs.sync)); + if (ret errno == EINTR) + continue; + if (ret == 0) { + ret = iargs.ret; + if (ret == 0) + *tid = ltid; + break; + } + ret = -errno; + if (detachstate == PTHREAD_CREATE_JOINABLE) + pthread_join(ltid, NULL); + panic(regular sem_wait() failed with %s, symerror(ret)); + } __cobalt_thread_harden(); /* May fail if regular thread. */ - ret = iargs.ret; - if (ret == 0) - *tid = ltid; - else if (detachstate == PTHREAD_CREATE_JOINABLE) - pthread_join(ltid, NULL); fail: __STD(sem_destroy(iargs.sync)); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git