If the uds transport returns an error, the subscriber is automatically
removed.

Signed-off-by: Michael Walle <mich...@walle.cc>
---
 clock.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/clock.c b/clock.c
index faf2dea..feda257 100644
--- a/clock.c
+++ b/clock.c
@@ -237,9 +237,9 @@ void clock_send_notification(struct clock *c, struct 
ptp_message *msg,
        unsigned int event_pos = event / 8;
        uint8_t mask = 1 << (event % 8);
        struct port *uds = c->uds_port;
-       struct clock_subscriber *s;
+       struct clock_subscriber *s, *tmp;
 
-       LIST_FOREACH(s, &c->subscribers, list) {
+       LIST_FOREACH_SAFE(s, &c->subscribers, list, tmp) {
                if (!(s->events[event_pos] & mask))
                        continue;
                /* send event */
@@ -250,7 +250,12 @@ void clock_send_notification(struct clock *c, struct 
ptp_message *msg,
                msg->management.targetPortIdentity.portNumber =
                        htons(s->targetPortIdentity.portNumber);
                msg->address = s->addr;
-               port_forward_to(uds, msg);
+               if (port_forward_to(uds, msg)) {
+                       /* remove the subscriber in case of an error */
+                       pr_info("subscriber %s removed due to delivery error",
+                                       pid2str(&s->targetPortIdentity));
+                       remove_subscriber(s);
+               }
        }
 }
 
-- 
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to