summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-04-01 02:41:02 -0400
committerEric S. Raymond <esr@thyrsus.com>2015-04-01 02:41:02 -0400
commit90e1d453f282f014a959260764431e64a791942d (patch)
treedd3137c312202089a8ee5df5a37a78e848397bfd
parentca3731143371a2b064f42b97c370ef54bfacb654 (diff)
downloadgpsd-90e1d453f282f014a959260764431e64a791942d.tar.gz
Thread monitor interface simplification.
With a bit of refactoring we can eliminate one of the hooks. PPS observed live, telnetting to localhost:2947 with gpsd running.
-rw-r--r--libgpsd_core.c1
-rw-r--r--ppsthread.c6
-rw-r--r--ppsthread.h2
-rw-r--r--timehint.c4
4 files changed, 5 insertions, 8 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c
index ce023f63..306bca13 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -422,7 +422,6 @@ void gpsd_clear(struct gps_device_t *session)
memset((void *)&session->pps_thread, 0, sizeof(session->pps_thread));
session->pps_thread.devicefd = session->gpsdata.gps_fd;
session->pps_thread.devicename = session->gpsdata.dev.path;
- session->pps_thread.pps_hook = NULL;
session->pps_thread.log_hook = ppsthread_log;
session->pps_thread.context = (void *)session;
#endif /* PPS_ENABLE */
diff --git a/ppsthread.c b/ppsthread.c
index 1f770074..1b9aba03 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -758,8 +758,7 @@ static void *gpsd_ppsmonitor(void *arg)
* a few more sanity checks
* call the report hook with our PPS report
*/
- while (thread_context->report_hook != NULL
- || thread_context->pps_hook != NULL) {
+ while (thread_context->report_hook != NULL) {
bool ok = false;
char *log = NULL;
char *edge_str = "";
@@ -1149,8 +1148,6 @@ static void *gpsd_ppsmonitor(void *arg)
log1 = thread_context->report_hook(thread_context, &ppstimes);
else
log1 = "no report hook";
- if (thread_context->pps_hook != NULL)
- thread_context->pps_hook(thread_context, &ppstimes);
thread_lock(thread_context);
thread_context->ppsout_last = ppstimes;
thread_context->ppsout_count++;
@@ -1233,7 +1230,6 @@ void pps_thread_deactivate(volatile struct pps_thread_t *pps_thread)
/* cleanly terminate PPS thread */
{
pps_thread->report_hook = NULL;
- pps_thread->pps_hook = NULL;
}
void pps_thread_fixin(volatile struct pps_thread_t *pps_thread,
diff --git a/ppsthread.h b/ppsthread.h
index a115163a..e5134e79 100644
--- a/ppsthread.h
+++ b/ppsthread.h
@@ -27,8 +27,6 @@ struct pps_thread_t {
char *devicename;
char *(*report_hook)(volatile struct pps_thread_t *,
struct timedelta_t *);
- void (*pps_hook)(volatile struct pps_thread_t *,
- struct timedelta_t *);
void (*log_hook)(volatile struct pps_thread_t *,
int errlevel, const char *fmt, ...);
void (*wrap_hook)(volatile struct pps_thread_t *);
diff --git a/timehint.c b/timehint.c
index c0502d61..0a6ebd69 100644
--- a/timehint.c
+++ b/timehint.c
@@ -381,6 +381,10 @@ static char *report_hook(volatile struct pps_thread_t *pps_thread,
if (session->shm_pps != NULL)
(void)ntpshm_put(session, session->shm_pps, td);
+ /* session context might have a hook set, too */
+ if (session->context->pps_hook != NULL)
+ session->context->pps_hook(session, td);
+
return log1;
}
#endif /* PPS_ENABLE */