diff options
Diffstat (limited to 'src/bus.c')
-rw-r--r-- | src/bus.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -723,7 +723,7 @@ const char * bus_poll(bus_t *bus, int flags) { int state = 0, saved_errno; - (void) flags; /* TODO nonblocking */ + (void) flags; if (!bus->first_poll) { t(release_semaphore(bus, W, SEM_UNDO)); state++; t(acquire_semaphore(bus, S, SEM_UNDO)); state++; @@ -734,8 +734,9 @@ bus_poll(bus_t *bus, int flags) } else { bus->first_poll = 0; } + state--; t(release_semaphore(bus, Q, 0)); - t(zero_semaphore(bus, Q, 0)); + t(zero_semaphore(bus, Q, F(BUS_NOWAIT, IPC_NOWAIT))); return bus->message; fail: @@ -744,6 +745,8 @@ fail: release_semaphore(bus, S, SEM_UNDO); if (state > 0) acquire_semaphore(bus, W, SEM_UNDO); + if (state < 0) + bus->first_poll = 1; errno = saved_errno; return NULL; } |