From d4e761138ec1016957199708e0fd0027300bedd2 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Wed, 12 Sep 2012 17:06:34 +0200 Subject: [PATCH] bugfix: use a sensible test to detect a new master. The code to detect a new master used pointer equality using a stale pointer within the clock instance. Instead, the clock needs to remember the identity of the foreign master in order to correctly detect a change of master. Signed-off-by: Richard Cochran --- clock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clock.c b/clock.c index 6136050..92ff9e4 100644 --- a/clock.c +++ b/clock.c @@ -61,6 +61,7 @@ struct clock { struct timePropertiesDS tds; struct ClockIdentity ptl[PATH_TRACE_MAX]; struct foreign_clock *best; + struct ClockIdentity best_id; struct port *port[CLK_N_PORTS]; struct pollfd pollfd[CLK_N_PORTS*N_CLOCK_PFD]; int fault_fd[CLK_N_PORTS]; @@ -836,13 +837,14 @@ static void handle_state_decision_event(struct clock *c) pr_notice("selected best master clock %s", cid2str(&best->dataset.identity)); - if (c->best != best) { + if (!cid_eq(&best->dataset.identity, &c->best_id)) { clock_freq_est_reset(c); mave_reset(c->avg_delay); fresh_best = 1; } c->best = best; + c->best_id = best->dataset.identity; for (i = 0; i < c->nports; i++) { enum port_state ps;