fix sem error for linux

This commit is contained in:
tumbili
2015-12-01 15:55:21 +01:00
parent 33f85a5024
commit f91af2221f
2 changed files with 6 additions and 5 deletions
+3
View File
@@ -301,6 +301,9 @@ extern "C" {
// Execute a blocking wait for that time in the future
errno = 0;
ret = px4_sem_timedwait(&sem, &ts);
#ifndef __PX4_DARWIN
ret = errno;
#endif
// Ensure ret is negative on failure
if (ret > 0) {
+3 -5
View File
@@ -95,6 +95,7 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime)
}
s->value--;
errno = 0;
if (s->value < 0) {
ret = pthread_cond_timedwait(&(s->wait), &(s->lock), abstime);
@@ -103,10 +104,7 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime)
ret = 0;
}
int err = errno;
#ifdef __PX4_DARWIN
err = ret;
#endif
int err = ret;
if (err != 0 && err != ETIMEDOUT) {
setbuf(stdout, NULL);
@@ -119,7 +117,7 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime)
int mret = pthread_mutex_unlock(&(s->lock));
return (ret) ? ret : mret;
return (err) ? err : mret;
}
int px4_sem_post(px4_sem_t *s)