commit 272108d851d6545f193ffc8ea0e2eefd2b2bc42d (HEAD -> master, origin/master, origin/HEAD) Author: Jared Hagel Date: Mon Aug 16 17:11:08 2021 -0700 gpsd/gpsd.c: Fix pselect() commit so it actually works. Signed-off-by: Gary E. Miller diff --git a/gpsd/gpsd.c b/gpsd/gpsd.c index 9151a6124..c1876f366 100644 --- a/gpsd/gpsd.c +++ b/gpsd/gpsd.c @@ -2428,6 +2428,8 @@ int main(int argc, char *argv[]) switch(gpsd_await_data(&rfds, &efds, maxfd, &all_fds, &context.errout)) { case AWAIT_GOT_INPUT: + FALLTHROUGH + case AWAIT_TIMEOUT: break; case AWAIT_NOT_READY: for (device = devices; device < devices + MAX_DEVICES; device++) diff --git a/gpsd/libgpsd_core.c b/gpsd/libgpsd_core.c index 2aa3537b8..b39d32be0 100644 --- a/gpsd/libgpsd_core.c +++ b/gpsd/libgpsd_core.c @@ -1301,7 +1301,7 @@ int gpsd_await_data(fd_set *rfds, struct gpsd_errout_t *errout) { int status; - timespec_t ts_timeout = {3, 0}; // timeout for pselect() + const timespec_t ts_timeout = {5, 0}; // timeout for pselect() FD_ZERO(efds); *rfds = *all_fds; @@ -1315,8 +1315,9 @@ int gpsd_await_data(fd_set *rfds, * low-clock-rate SBCs and the like). * * As used here, there is no difference between pselect() - * or select(). A 3 second timeout is used, this adds a bit - * of power consumption, but prevents infinite hang during autobaud. + * or select(). A 5 second timeout is used, this adds a bit + * of power consumption, but prevents infinite hang during autobaud, + * or select. */ errno = 0; @@ -1338,6 +1339,10 @@ int gpsd_await_data(fd_set *rfds, } return AWAIT_NOT_READY; } + if (0 == status) { + return AWAIT_TIMEOUT; + } + // else GPSD_LOG(LOG_ERROR, errout, "select: %s\n", strerror(errno)); return AWAIT_FAILED; diff --git a/include/gpsd.h b/include/gpsd.h index 531ef822c..7b94dca8f 100644 --- a/include/gpsd.h +++ b/include/gpsd.h @@ -1019,6 +1019,7 @@ extern int gpsd_open(struct gps_device_t *); extern int gpsd_activate(struct gps_device_t *, const int); extern void gpsd_deactivate(struct gps_device_t *); +#define AWAIT_TIMEOUT 2 #define AWAIT_GOT_INPUT 1 #define AWAIT_NOT_READY 0 #define AWAIT_FAILED -1