diff options
Diffstat (limited to '')
-rw-r--r-- | src/bus.c | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -415,6 +415,7 @@ bus_create(const char *file, int flags, char **out_file) bus.key_sem = -1; bus.key_shm = -1; bus.message = NULL; + bus.first_poll = 0; srand((unsigned int)time(NULL) + (unsigned int)rand()); @@ -667,8 +668,9 @@ fail: int -bus_poll_start(const bus_t *bus) +bus_poll_start(bus_t *bus) { + bus->first_poll = 1; return release_semaphore(bus, S, SEM_UNDO); } @@ -680,23 +682,17 @@ bus_poll_stop(const bus_t *bus) } -int -bus_poll_continue(const bus_t *bus) -{ - t(release_semaphore(bus, W, SEM_UNDO)); - t(acquire_semaphore(bus, S, SEM_UNDO)); - t(zero_semaphore(bus, S)); - t(release_semaphore(bus, S, SEM_UNDO)); - t(acquire_semaphore(bus, W, SEM_UNDO)); - return 0; -fail: - return -1; -} - - const char * bus_poll(const bus_t *bus) { + if (bus->first_poll) { + bus->first_poll = 0; + t(release_semaphore(bus, W, SEM_UNDO)); + t(acquire_semaphore(bus, S, SEM_UNDO)); + t(zero_semaphore(bus, S)); + t(release_semaphore(bus, S, SEM_UNDO)); + t(acquire_semaphore(bus, W, SEM_UNDO)); + } t(release_semaphore(bus, Q, 0)); t(zero_semaphore(bus, Q)); return bus->message; |