From 39b10a5a167627a5a3ab87d462e9a50da020bbf7 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Wed, 21 Mar 2012 13:08:09 +0100 Subject: [PATCH] Add a method to remove a port from the clock's polling array. Signed-off-by: Richard Cochran --- clock.c | 14 ++++++++++++++ clock.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/clock.c b/clock.c index 914bfc0..fa99d86 100644 --- a/clock.c +++ b/clock.c @@ -368,6 +368,20 @@ void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, pr_debug("path delay %10lld %10lld", c->path_delay, pd); } +void clock_remove_fda(struct clock *c, struct port *p, struct fdarray fda) +{ + int i, j, k; + for (i = 0; i < c->nports; i++) { + if (p == c->port[i]) + break; + } + for (j = 0; j < fda.cnt; j++) { + k = N_POLLFD * i + j; + c->pollfd[k].fd = -1; + c->pollfd[k].events = 0; + } +} + int clock_slave_only(struct clock *c) { return c->dds.slaveOnly; diff --git a/clock.h b/clock.h index 5e94b68..42ee692 100644 --- a/clock.h +++ b/clock.h @@ -135,6 +135,14 @@ void clock_path_delay(struct clock *c, struct timespec req, struct timestamp rx, */ int clock_poll(struct clock *c); +/** + * Remove a port's file descriptor array from its controlling clock. + * @param c The clock instance. + * @param p The port removing the array. + * @param fda The port's file decriptor array. + */ +void clock_remove_fda(struct clock *c, struct port *p, struct fdarray fda); + /** * Obtain the slave-only flag from a clock's default data set. * @param c The clock instance.