Correctly handle a negative log message interval.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
d7a67e9f89
commit
6ad9af1a25
8
port.c
8
port.c
|
@ -111,9 +111,15 @@ static void announce_to_dataset(struct ptp_message *m, struct clock *c,
|
||||||
static int msg_current(struct ptp_message *m, struct timespec now)
|
static int msg_current(struct ptp_message *m, struct timespec now)
|
||||||
{
|
{
|
||||||
int64_t t1, t2, tmo;
|
int64_t t1, t2, tmo;
|
||||||
|
|
||||||
t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
|
t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
|
||||||
t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
|
t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
|
||||||
tmo = 4 * (1 << m->header.logMessageInterval) * NSEC2SEC;
|
|
||||||
|
if (m->header.logMessageInterval < 0)
|
||||||
|
tmo = 4LL * NSEC2SEC / (1 << -m->header.logMessageInterval);
|
||||||
|
else
|
||||||
|
tmo = 4LL * (1 << m->header.logMessageInterval) * NSEC2SEC;
|
||||||
|
|
||||||
return t2 - t1 < tmo;
|
return t2 - t1 < tmo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue