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" {
// Execute a blocking wait for that time in the future // Execute a blocking wait for that time in the future
errno = 0; errno = 0;
ret = px4_sem_timedwait(&sem, &ts); ret = px4_sem_timedwait(&sem, &ts);
#ifndef __PX4_DARWIN
ret = errno;
#endif
// Ensure ret is negative on failure // Ensure ret is negative on failure
if (ret > 0) { 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)
} }
s->value--; s->value--;
errno = 0;
if (s->value < 0) { if (s->value < 0) {
ret = pthread_cond_timedwait(&(s->wait), &(s->lock), abstime); 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; ret = 0;
} }
int err = errno; int err = ret;
#ifdef __PX4_DARWIN
err = ret;
#endif
if (err != 0 && err != ETIMEDOUT) { if (err != 0 && err != ETIMEDOUT) {
setbuf(stdout, NULL); 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)); int mret = pthread_mutex_unlock(&(s->lock));
return (ret) ? ret : mret; return (err) ? err : mret;
} }
int px4_sem_post(px4_sem_t *s) int px4_sem_post(px4_sem_t *s)

Loading…
Cancel
Save