summaryrefslogtreecommitdiff
path: root/libgpsd_core.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-07 01:57:32 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-03-07 01:57:32 -0500
commite92b21041e00778c72362620ad9d62ffa94613db (patch)
tree2871a2dda9955daabb8efab913cd3b13684cb8f8 /libgpsd_core.c
parent02c9c43a3aaaf73f84fdf9fbc96e9a32e546d273 (diff)
downloadgpsd-e92b21041e00778c72362620ad9d62ffa94613db.tar.gz
Another step in prying ntplib loose. Partly decouple ppsthread.c fom sessions.
All regression tests pass.
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r--libgpsd_core.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 7fae7006..d9db154a 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -307,8 +307,7 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context,
/*@i2@*/session->last_fixtime.clock.tv_sec = 0;
/*@i2@*/session->last_fixtime.clock.tv_nsec = 0;
#ifdef PPS_ENABLE
- memset( (void *)&session->ppslast, 0, sizeof(session->ppslast));
- session->ppscount = 0;
+ memset((void *)&session->pps_state, 0, sizeof(session->pps_state));
#endif /* PPS_ENABLE */
/*@ -mayaliasunique @*/
@@ -406,8 +405,7 @@ void gpsd_clear(struct gps_device_t *session)
/*@i2@*/session->last_fixtime.clock.tv_sec = 0;
/*@i2@*/session->last_fixtime.clock.tv_nsec = 0;
#ifdef PPS_ENABLE
- memset( (void *)&session->ppslast, 0, sizeof(session->ppslast));
- session->ppscount = 0;
+ memset((void *)&session->pps_state, 0, sizeof(session->pps_state));
#endif /* PPS_ENABLE */
session->opentime = timestamp();
@@ -1619,6 +1617,7 @@ void ntp_latch(struct gps_device_t *device, struct timedelta_t /*@out@*/*td)
/* latch the fact that we've saved a fix */
{
double fix_time, integral, fractional;
+ int status;
/* this should be an invariant of the way this function is called */
assert(isnan(device->newdata.time)==0);
@@ -1648,8 +1647,20 @@ void ntp_latch(struct gps_device_t *device, struct timedelta_t /*@out@*/*td)
#ifdef PPS_ENABLE
/* thread-safe update */
/*@-compdef@*/
- pps_thread_stash_fixtime(device, device->newdata.time, td->clock);
+ status = pps_thread_stash_fixtime(&device->last_fixtime,
+ device->newdata.time, td->clock);
/*@+compdef@*/
+ if (status == PPS_LOCK_ERR) {
+ char errbuf[BUFSIZ] = "unknown error";
+ (void)strerror_r(errno, errbuf,(int) sizeof(errbuf));
+ gpsd_report(&device->context->errout, LOG_ERROR,
+ "PPS: pthread_mutex_unlock() : %s\n", errbuf);
+ } else if (status == PPS_LOCK_ERR) {
+ char errbuf[BUFSIZ] = "unknown error";
+ (void)strerror_r(errno, errbuf,(int) sizeof(errbuf));
+ gpsd_report(&device->context->errout, LOG_ERROR,
+ "PPS: pthread_mutex_lock() : %s\n", errbuf);
+ }
#endif /* PPS_ENABLE */
}
#endif /* NTP_ENABLE */