diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2006-09-28 04:48:52 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2006-09-28 04:48:52 +0000 |
commit | 54d6b2b6ff04687590156838efa537163f2d6bd3 (patch) | |
tree | 81d1d6e68af6d3533250e711caf16c9190f9c19f /dgnss.c | |
parent | 3deecfbc77d5d0868a99b03e661086a17c8bd282 (diff) | |
download | gpsd-54d6b2b6ff04687590156838efa537163f2d6bd3.tar.gz |
Prevent gpsd from spinning if the dgpsip stream goes away.
Reported by Neal Probert on gpsd-dev
Diffstat (limited to 'dgnss.c')
-rw-r--r-- | dgnss.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,6 +1,8 @@ /* $Id$ */ /* dgnss.c -- common interface to a number of Differential GNSS services */ +#include <sys/types.h> +#include <sys/socket.h> #include <string.h> #include <unistd.h> #include <errno.h> @@ -44,16 +46,20 @@ int dgnss_open(struct gps_context_t *context, char *dgnss_service) } /*@ +branchstate */ -void dgnss_poll(struct gps_context_t *context) +int dgnss_poll(struct gps_context_t *context) /* poll the DGNSS service for a correction report */ { if (context->dsock > -1) { context->rtcmbytes = read(context->dsock, context->rtcmbuf, sizeof(context->rtcmbuf)); - if (context->rtcmbytes < 0 && errno != EAGAIN) - gpsd_report(1, "Read from rtcm source failed\n"); - else + if ((context->rtcmbytes == -1 && errno != EAGAIN) || + (context->rtcmbytes == 0)) { + shutdown(context->dsock, SHUT_RDWR); + close(context->dsock); + return -1; + } else context->rtcmtime = timestamp(); } + return 0; } void dgnss_report(struct gps_device_t *session) |