From 27421a355f42c6303cae74a861a86f5c96d29d18 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 1 Apr 2015 04:13:59 -0400 Subject: Further thread-monitor interface simplification. Remove the wrap hook. The only thing it was doing was closing the chrony fd. which can be done just as cleanly by whatever calls the pps_thread_deactivate() function. --- ppsthread.c | 2 -- ppsthread.h | 5 +---- timehint.c | 10 ++-------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/ppsthread.c b/ppsthread.c index d3d9fd64..df46c64f 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -1177,8 +1177,6 @@ static void *gpsd_ppsmonitor(void *arg) (void)time_pps_destroy(inner_context.kernelpps_handle); } #endif - if (thread_context->wrap_hook != NULL) - thread_context->wrap_hook(thread_context); thread_context->log_hook(thread_context, THREAD_PROG, "PPS:%s gpsd_ppsmonitor exited.\n", thread_context->devicename); diff --git a/ppsthread.h b/ppsthread.h index 5c95e72b..6dc18964 100644 --- a/ppsthread.h +++ b/ppsthread.h @@ -31,9 +31,7 @@ struct timedelta_t { * two functions are for. * * The report hook is called when each PPS event is recognized. The log - * hook is called to log error and status indications from the thread. The - * wrap hook is called when the thread terminates as the result of a - * deactivate call. + * hook is called to log error and status indications from the thread. */ struct pps_thread_t { void *context; /* PPS thread code leaves this alone */ @@ -43,7 +41,6 @@ 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 *); struct timedelta_t fix_in; /* real & clock time when in-band fix received */ struct timedelta_t pps_out; /* real & clock time of last PPS event */ int ppsout_count; diff --git a/timehint.c b/timehint.c index 0a6ebd69..e1921c3f 100644 --- a/timehint.c +++ b/timehint.c @@ -344,13 +344,6 @@ static void chrony_send(struct gps_device_t *session, struct timedelta_t *td) (void)send(session->chronyfd, &sample, sizeof (sample), 0); } -static void wrap_hook(volatile struct pps_thread_t *pps_thread) -{ - struct gps_device_t *session = (struct gps_device_t *)pps_thread->context; - if (session->chronyfd != -1) - (void)close(session->chronyfd); -} - static char *report_hook(volatile struct pps_thread_t *pps_thread, struct timedelta_t *td) /* ship the time of a PPS event to ntpd and/or chrony */ @@ -399,6 +392,8 @@ void ntpshm_link_deactivate(struct gps_device_t *session) #if defined(PPS_ENABLE) if (session->shm_pps != NULL) { pps_thread_deactivate(&session->pps_thread); + if (session->chronyfd != -1) + (void)close(session->chronyfd); (void)ntpshm_free(session->context, session->shm_pps); session->shm_pps = NULL; } @@ -437,7 +432,6 @@ void ntpshm_link_activate(struct gps_device_t *session) } else { init_hook(session); session->pps_thread.report_hook = report_hook; - session->pps_thread.wrap_hook = wrap_hook; pps_thread_activate(&session->pps_thread); } #endif /* PPS_ENABLE */ -- cgit v1.2.1