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 <richardcochran@gmail.com>
master
Richard Cochran 2020-04-03 07:11:42 -07:00
parent 1044268e85
commit 2f0bfb2837
1 changed files with 12 additions and 7 deletions

View File

@ -18,8 +18,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#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;