diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2018-12-27 05:39:42 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2018-12-27 05:39:42 -0500 |
commit | 1998c0301f6f9542bf5dd51e8d18f3d7f4e76023 (patch) | |
tree | 47b092141978039c773e4a4e9f992eab90ee340b /libgps_sock.c | |
parent | e81cfb77ab1a8de2e7cac6883e632124bcbe6f35 (diff) | |
download | gpsd-1998c0301f6f9542bf5dd51e8d18f3d7f4e76023.tar.gz |
Factor most uses of pselect(2) into a new utility function named 'nanowait'.
Also, remove sime header inclusions discovered to be unnecessary during
the change.
Diffstat (limited to 'libgps_sock.c')
-rw-r--r-- | libgps_sock.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/libgps_sock.c b/libgps_sock.c index 808d837a..7816014d 100644 --- a/libgps_sock.c +++ b/libgps_sock.c @@ -13,7 +13,6 @@ #include <math.h> #include <locale.h> #include <assert.h> -#include <sys/time.h> /* expected to have a pselect(2) prototype a la SuS */ #include <sys/types.h> #include <sys/stat.h> #include "gpsd_config.h" @@ -132,22 +131,12 @@ bool gps_sock_waiting(const struct gps_data_t *gpsdata, int timeout) /* timeout is in uSec */ { #ifndef USE_QT - fd_set rfds; - struct timespec tv; - libgps_debug_trace((DEBUG_CALLS, "gps_waiting(%d): %d\n", timeout, PRIVATE(gpsdata)->waitcount++)); if (PRIVATE(gpsdata)->waiting > 0) return true; - /* we might want to check for EINTR if this returns false */ - errno = 0; - - FD_ZERO(&rfds); - FD_SET(gpsdata->gps_fd, &rfds); - tv.tv_sec = timeout / US_IN_SEC; - tv.tv_nsec = (timeout % US_IN_SEC) * 1000; /* all error conditions return "not waiting" -- crude but effective */ - return (pselect(gpsdata->gps_fd + 1, &rfds, NULL, NULL, &tv, NULL) == 1); + return nanowait(gpsdata->gps_fd, timeout * 1000); #else return ((QTcpSocket *) (gpsdata->gps_fd))->waitForReadyRead(timeout / 1000); #endif |