Browse Source

fix sem error for linux

sbg
tumbili 9 years ago
parent
commit
f91af2221f
  1. 3
      src/drivers/device/vdev_posix.cpp
  2. 8
      src/platforms/posix/px4_layer/px4_sem.cpp

3
src/drivers/device/vdev_posix.cpp

@ -301,6 +301,9 @@ extern "C" { @@ -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) {

8
src/platforms/posix/px4_layer/px4_sem.cpp

@ -95,6 +95,7 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime) @@ -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) @@ -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) @@ -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)

Loading…
Cancel
Save