On Tue, Apr 24, 2018 at 05:13:11PM +0100, Richard Hill wrote:
> > Or should the list never be empty at this point ?
>
> The list can't be empty. Here is why.
I am so wrong. The list *can* be empty if the FD_ANNOUNCE_TIMER and
the FD_DELAY_TIMER expire at the same time. In this case, the poll()
call indicates events on both file descriptors. The announce timeout
is handled like this:
case FD_SYNC_RX_TIMER:
if (p->best)
fc_clear(p->best);
So then the port_delay_request() call de-references the null
TAILQ_FIRST message pointer.
> Version is unmodified 1.8
>
> What might be relevant is the type of testing I was doing. This was
> operating slaveOnly. Other Masters were appearing and disappearing quite
> often. I had this NULL pointer twice over a full day.
Can you apply this patch to v1.8 and see if that fixes the problem?
Thanks,
Richard
---
diff --git a/fd.h b/fd.h
index e328e98..56023a3 100644
--- a/fd.h
+++ b/fd.h
@@ -25,15 +25,17 @@
enum {
FD_EVENT,
FD_GENERAL,
+ FD_DELAY_TIMER,
FD_ANNOUNCE_TIMER,
FD_SYNC_RX_TIMER,
- FD_DELAY_TIMER,
FD_QUALIFICATION_TIMER,
FD_MANNO_TIMER,
FD_SYNC_TX_TIMER,
N_POLLFD,
};
+#define FD_FIRST_TIMER FD_DELAY_TIMER
+
struct fdarray {
int fd[N_POLLFD];
};
diff --git a/port.c b/port.c
index a1ad6f6..e6e7c20 100644
--- a/port.c
+++ b/port.c
@@ -1446,7 +1446,7 @@ static void port_disable(struct port *p)
transport_close(p->trp, &p->fda);
for (i = 0; i < N_TIMER_FDS; i++) {
- close(p->fda.fd[FD_ANNOUNCE_TIMER + i]);
+ close(p->fda.fd[FD_FIRST_TIMER + i]);
}
port_clear_fda(p, N_POLLFD);
clock_fda_changed(p->clock);
@@ -1486,7 +1486,7 @@ static int port_initialize(struct port *p)
goto no_tropen;
for (i = 0; i < N_TIMER_FDS; i++) {
- p->fda.fd[FD_ANNOUNCE_TIMER + i] = fd[i];
+ p->fda.fd[FD_FIRST_TIMER + i] = fd[i];
}
if (port_set_announce_tmo(p))
@@ -1516,7 +1516,7 @@ static int port_renew_transport(struct port *p)
return 0;
}
transport_close(p->trp, &p->fda);
- port_clear_fda(p, FD_ANNOUNCE_TIMER);
+ port_clear_fda(p, FD_FIRST_TIMER);
res = transport_open(p->trp, p->name, &p->fda, p->timestamping);
/* Need to call clock_fda_changed even if transport_open failed in
* order to update clock to the now closed descriptors. */
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-users