From b73abff012abacf770a9f59fb054b721e2b9e336 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 2 Feb 2015 18:09:32 -0500 Subject: Revert the change abolishing the "pps" policy flag, it broke gpsmon client mode. All regression tests pass. --- gpsd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gpsd.c') diff --git a/gpsd.c b/gpsd.c index 3b451532..3d19ffff 100644 --- a/gpsd.c +++ b/gpsd.c @@ -626,6 +626,7 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf, } static void notify_watchers(struct gps_device_t *device, + bool onjson, bool onpps, const char *sentence, ...) /* notify all JSON-watching clients of a given device about an event */ { @@ -639,7 +640,7 @@ static void notify_watchers(struct gps_device_t *device, for (sub = subscribers; sub < subscribers + MAX_CLIENTS; sub++) if (sub->active != 0 && subscribed(sub, device)) { - if (sub->policy.json) + if ((onjson && sub->policy.json) || (onpps && sub->policy.pps)) (void)throttled_write(sub, buf, strlen(buf)); } } @@ -649,7 +650,7 @@ static void deactivate_device(struct gps_device_t *device) /* deactivate device, but leave it in the pool (do not free it) */ { #ifdef SOCKET_EXPORT_ENABLE - notify_watchers(device, + notify_watchers(device, true, false, "{\"class\":\"DEVICE\",\"path\":\"%s\",\"activated\":0}\r\n", device->gpsdata.dev.path); #endif /* SOCKET_EXPORT_ENABLE */ @@ -738,7 +739,7 @@ bool gpsd_add_device(const char *device_name, bool flag_nowait) ret = open_device(devp); } #ifdef SOCKET_EXPORT_ENABLE - notify_watchers(devp, + notify_watchers(devp, true, false, "{\"class\":\"DEVICE\",\"path\":\"%s\",\"activated\":%lf}\r\n", devp->gpsdata.dev.path, timestamp()); #endif /* SOCKET_EXPORT_ENABLE */ @@ -1460,7 +1461,7 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) { char id2[GPS_JSON_RESPONSE_MAX]; json_device_dump(device, id2, sizeof(id2)); - notify_watchers(device, id2); + notify_watchers(device, true, false, id2); } } #endif /* SOCKET_EXPORT_ENABLE */ @@ -1652,7 +1653,7 @@ static void ship_pps_drift_message(struct gps_device_t *session, /* on PPS interrupt, ship a drift message to all clients */ { /*@-type@*//* splint is confused about struct timespec */ - notify_watchers(session, + notify_watchers(session, true, true, "{\"class\":\"PPS\",\"device\":\"%s\",\"real_sec\":%ld, \"real_nsec\":%ld,\"clock_sec\":%ld,\"clock_nsec\":%ld}\r\n", session->gpsdata.dev.path, td->real.tv_sec, td->real.tv_nsec, -- cgit v1.2.1