diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-10-31 22:44:28 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-10-31 22:44:28 -0400 |
commit | 1703033e9476f8368492c0881f9b5ec36752133b (patch) | |
tree | ee3bfcb9ec3d36aa6830f0db4cb265c33b319e81 /gpsd.c | |
parent | 667fc1ff32cd0e112f0cf43b3b49227712cdc086 (diff) | |
download | gpsd-1703033e9476f8368492c0881f9b5ec36752133b.tar.gz |
Move NTP link activation from device stash time to device open time.
Fixes a subtle bug resulting from the device source type not being
known at link activation time. We had to choose between trying to
filter on source type and having PPS blocked, or not filtering
abd having the tests hang.
All regression tests pass. PPS is live.
Diffstat (limited to 'gpsd.c')
-rw-r--r-- | gpsd.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -694,6 +694,22 @@ static bool open_device( /*@null@*/struct gps_device_t *device) if (NULL == device || gpsd_activate(device, O_OPTIMIZE) < 0) { return false; } +#ifdef NTPSHM_ENABLE + /* + * Now is the right time to grab the shared memory segment(s) + * to communicate the navigation message derived and (possibly) + * 1PPS derived time data to ntpd/chrony. + */ + /* do not start more than one PPS-watcher thread */ + if (!(device->shmindex >= 0)) + ntpd_link_activate(device); + + gpsd_report(context.debug, LOG_INF, + "NTPD ntpd_link_activate: %d\n", + (int)device->shmindex >= 0); + + +#endif /* NTPSHM_ENABLE */ gpsd_report(context.debug, LOG_INF, "device %s activated\n", device->gpsdata.dev.path); FD_SET(device->gpsdata.gps_fd, &all_fds); @@ -717,22 +733,6 @@ bool gpsd_add_device(const char *device_name, bool flag_nowait) for (devp = devices; devp < devices + MAXDEVICES; devp++) if (!allocated_device(devp)) { gpsd_init(devp, &context, device_name); -#ifdef NTPSHM_ENABLE - /* - * Now is the right time to grab the shared memory segment(s) - * to communicate the navigation message derived and (possibly) - * 1pps derived time data to ntpd. - */ - - /* do not start more than one ntp thread */ - if (!(devp->shmindex >= 0)) - ntpd_link_activate(devp); - - gpsd_report(context.debug, LOG_INF, - "NTPD ntpd_link_activate: %d\n", - (int)devp->shmindex >= 0); - -#endif /* NTPSHM_ENABLE */ gpsd_report(context.debug, LOG_INF, "stashing device %s at slot %d\n", device_name, (int)(devp - devices)); |