diff options
-rw-r--r-- | gpsctl.c | 11 | ||||
-rw-r--r-- | gpsd.c | 10 | ||||
-rw-r--r-- | gpsd.h-tail | 6 | ||||
-rw-r--r-- | gpsmon.c | 11 | ||||
-rw-r--r-- | libgpsd_core.c | 8 |
5 files changed, 38 insertions, 8 deletions
@@ -654,6 +654,17 @@ int main(int argc, char **argv) /* grab packets until we time out or get sync */ for (hunting = true; hunting; ) { + switch(gpsd_await_data(&rfds, maxfd, &all_fds, context.debug)) + { + case AWAIT_GOT_INPUT: + break; + case AWAIT_NOT_READY: + continue; + case AWAIT_FAILED: + exit(EXIT_FAILURE); + break; + } + if (!gpsd_await_data(&rfds, maxfd, &all_fds, context.debug)) continue; @@ -2123,8 +2123,16 @@ int main(int argc, char *argv[]) } while (0 == signalled) { - if (!gpsd_await_data(&rfds, maxfd, &all_fds, context.debug)) + switch(gpsd_await_data(&rfds, maxfd, &all_fds, context.debug)) + { + case AWAIT_GOT_INPUT: + break; + case AWAIT_NOT_READY: continue; + case AWAIT_FAILED: + exit(EXIT_FAILURE); + break; + } #ifdef SOCKET_EXPORT_ENABLE /* always be open to new client connections */ diff --git a/gpsd.h-tail b/gpsd.h-tail index 7b1804fc..a866f69f 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -826,7 +826,11 @@ extern int gpsd_open(struct gps_device_t *); #define O_OPTIMIZE 2 extern int gpsd_activate(struct gps_device_t *, const int); extern void gpsd_deactivate(struct gps_device_t *); -extern bool gpsd_await_data(/*@out@*/fd_set *, + +#define AWAIT_GOT_INPUT 1 +#define AWAIT_NOT_READY 0 +#define AWAIT_FAILED -1 +extern int gpsd_await_data(/*@out@*/fd_set *, const int, /*@in@*/fd_set *, const int); @@ -1011,9 +1011,16 @@ int main(int argc, char **argv) if ((bailout = setjmp(terminate)) == 0) { for (;;) { - /* FIXME: On non-EINTR select failure, throw TERM_SELECT_FAILED */ - if (!gpsd_await_data(&rfds, maxfd, &all_fds, context.debug)) + switch(gpsd_await_data(&rfds, maxfd, &all_fds, context.debug)) + { + case AWAIT_GOT_INPUT: + break; + case AWAIT_NOT_READY: continue; + case AWAIT_FAILED: + longjmp(terminate, TERM_SELECT_FAILED); + break; + } switch(gpsd_multipoll(FD_ISSET(session.gpsdata.gps_fd, &rfds), &session, monhook, 0)) diff --git a/libgpsd_core.c b/libgpsd_core.c index f7baaf38..da1d7256 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -966,7 +966,7 @@ static void gpsd_error_model(struct gps_device_t *session, #endif /* CHEAPFLOATS_ENABLE */ /*@ -mustdefine -compdef @*/ -bool gpsd_await_data(/*@out@*/fd_set *rfds, +int gpsd_await_data(/*@out@*/fd_set *rfds, const int maxfd, /*@in@*/fd_set *all_fds, const int debug) @@ -1003,9 +1003,9 @@ bool gpsd_await_data(/*@out@*/fd_set *rfds, #endif if (status == -1) { if (errno == EINTR) - return false; + return AWAIT_NOT_READY; gpsd_report(debug, LOG_ERROR, "select: %s\n", strerror(errno)); - exit(EXIT_FAILURE); + return AWAIT_FAILED; } /*@ +usedef +nullpass @*/ @@ -1028,7 +1028,7 @@ bool gpsd_await_data(/*@out@*/fd_set *rfds, dbuf, timestamp(), errno); } - return true; + return AWAIT_GOT_INPUT; } /*@ +mustdefine +compdef @*/ |