Update data sets after loss of foreign master.

If an announce timeout occurs on a port, and no other port is slaved, then
the clock must become a grand master by default.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-07-08 12:14:28 +02:00
parent 7ac297a082
commit c1973c5e11
1 changed files with 16 additions and 3 deletions

17
clock.c
View File

@ -95,6 +95,16 @@ static int clock_fault_timeout(struct clock *c, int index, int set)
return timerfd_settime(c->fault_fd[index], 0, &tmo, NULL); return timerfd_settime(c->fault_fd[index], 0, &tmo, NULL);
} }
static int clock_master_lost(struct clock *c)
{
int i;
for (i = 0; i < c->nports; i++) {
if (PS_SLAVE == port_state(c->port[i]))
return 0;
}
return 1;
}
static void clock_ppb(clockid_t clkid, double ppb) static void clock_ppb(clockid_t clkid, double ppb)
{ {
struct timex tx; struct timex tx;
@ -324,7 +334,7 @@ struct PortIdentity clock_parent_identity(struct clock *c)
int clock_poll(struct clock *c) int clock_poll(struct clock *c)
{ {
int cnt, i, j, k, sde = 0; int cnt, i, j, k, lost = 0, sde = 0;
enum fsm_event event; enum fsm_event event;
cnt = poll(c->pollfd, ARRAY_SIZE(c->pollfd), -1); cnt = poll(c->pollfd, ARRAY_SIZE(c->pollfd), -1);
@ -348,7 +358,8 @@ int clock_poll(struct clock *c)
event = port_event(c->port[i], j); event = port_event(c->port[i], j);
if (EV_STATE_DECISION_EVENT == event) if (EV_STATE_DECISION_EVENT == event)
sde = 1; sde = 1;
else if (EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES == event)
lost = 1;
port_dispatch(c->port[i], event, 0); port_dispatch(c->port[i], event, 0);
} }
} }
@ -366,6 +377,8 @@ int clock_poll(struct clock *c)
} }
} }
if (lost && clock_master_lost(c))
clock_update_grandmaster(c);
if (sde) if (sde)
handle_state_decision_event(c); handle_state_decision_event(c);