From 2f0bfb2837573c4dcbbe440e642aabda0e5d5131 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Fri, 3 Apr 2020 07:11:42 -0700 Subject: [PATCH] pmc: Allow multiple local subscribers. If more than one local UDS client subscribes to push notifications, only the last one receives data from the ptp4l service. This happens because ptp4l uses the PortIdentity as a unique key to track client subscriptions. As a result, it is not possible for both phc2sys and pmc to receive push notifications at the same time, for example. This patch sets the PortIdentity.portNumber attribute of UDS clients to the local process ID, making each such client subscription unique. Signed-off-by: Richard Cochran --- pmc_common.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pmc_common.c b/pmc_common.c index f89d87c..822dd6d 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -18,8 +18,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include -#include #include +#include +#include +#include #include "notification.h" #include "print.h" @@ -353,13 +355,16 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type, if (!pmc) return NULL; - if (transport_type != TRANS_UDS && - generate_clock_identity(&pmc->port_identity.clockIdentity, - iface_name)) { - pr_err("failed to generate a clock identity"); - goto failed; + if (transport_type == TRANS_UDS) { + pmc->port_identity.portNumber = getpid(); + } else { + if (generate_clock_identity(&pmc->port_identity.clockIdentity, + iface_name)) { + pr_err("failed to generate a clock identity"); + goto failed; + } + pmc->port_identity.portNumber = 1; } - pmc->port_identity.portNumber = 1; pmc_target_all(pmc); pmc->boundary_hops = boundary_hops;