clock: keep ports in specified order.

When adding a new port, put it at the end of the list instead of head.
This restores the order of received management messages as was before
commit 08575133.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2014-11-05 12:52:38 +01:00 committed by Richard Cochran
parent 594f59c50d
commit 50d5c63e16
1 changed files with 7 additions and 2 deletions

View File

@ -756,7 +756,7 @@ static int clock_add_port(struct clock *c, int phc_index,
enum timestamp_type timestamping, enum timestamp_type timestamping,
struct interface *iface) struct interface *iface)
{ {
struct port *p; struct port *p, *piter, *lastp = NULL;
if (clock_resize_pollfd(c, c->nports + 1)) if (clock_resize_pollfd(c, c->nports + 1))
return -1; return -1;
@ -766,7 +766,12 @@ static int clock_add_port(struct clock *c, int phc_index,
/* No need to shrink pollfd */ /* No need to shrink pollfd */
return -1; return -1;
} }
LIST_INSERT_HEAD(&c->ports, p, list); LIST_FOREACH(piter, &c->ports, list)
lastp = piter;
if (lastp)
LIST_INSERT_AFTER(lastp, p, list);
else
LIST_INSERT_HEAD(&c->ports, p, list);
c->nports++; c->nports++;
clock_fda_changed(c); clock_fda_changed(c);
return 0; return 0;