summaryrefslogtreecommitdiff
path: root/gps2udp.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2018-12-27 05:39:42 -0500
committerEric S. Raymond <esr@thyrsus.com>2018-12-27 05:39:42 -0500
commit1998c0301f6f9542bf5dd51e8d18f3d7f4e76023 (patch)
tree47b092141978039c773e4a4e9f992eab90ee340b /gps2udp.c
parente81cfb77ab1a8de2e7cac6883e632124bcbe6f35 (diff)
downloadgpsd-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 'gps2udp.c')
-rw-r--r--gps2udp.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/gps2udp.c b/gps2udp.c
index ea894689..b8b9c61f 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -18,7 +18,7 @@
/* #if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L */
#ifdef __linux__
/* breaks osX */
-/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
+/* isfinite() needs _POSIX_C_SOURCE >= 200112L */
#define _POSIX_C_SOURCE 200112L
#endif /* __linux__ */
@@ -50,6 +50,7 @@
#include "gpsdclient.h"
#include "revision.h"
#include "strfuncs.h"
+#include "timespec.h"
#define MAX_TIME_LEN 80
#define MAX_GPSD_RETRY 10
@@ -239,27 +240,17 @@ static void connect2gpsd(bool restart)
static ssize_t read_gpsd(char *message, size_t len)
/* get data from gpsd */
{
- struct timespec tv;
- fd_set fds,master;
int ind;
char c;
int retry=0;
- // prepare select structure */
- FD_ZERO(&master);
- FD_SET(gpsdata.gps_fd, &master);
-
/* allow room for trailing NUL */
len--;
/* loop until we get some data or an error */
for (ind = 0; ind < (int)len;) {
- int result;
/* prepare for a blocking read with a 10s timeout */
- tv.tv_sec = 10;
- tv.tv_nsec = 0;
- fds = master;
- result = pselect(gpsdata.gps_fd+1, &fds, NULL, NULL, &tv, NULL);
+ int result = nanowait(gpsdata.gps_fd, 10 % NS_IN_SEC);
switch (result)
{