summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-02 18:09:32 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-02 18:11:22 -0500
commitb73abff012abacf770a9f59fb054b721e2b9e336 (patch)
treeef0fa6b7fcea597905e61bea9ea3403b01f9e151 /gpsd.c
parent7aed6d1d79289ac2bf15e4509d5f79a84b0dc177 (diff)
downloadgpsd-b73abff012abacf770a9f59fb054b721e2b9e336.tar.gz
Revert the change abolishing the "pps" policy flag, it broke gpsmon client mode.
All regression tests pass.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c11
1 files changed, 6 insertions, 5 deletions
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,