This allows running multiple phc2sys and pmc instances at the same time.

Signed-off-by: Miroslav Lichvar <mlich...@redhat.com>
---
 phc2sys.c |  7 +++++--
 pmc.8     |  2 +-
 pmc.c     | 12 +++++++++---
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 3039e51..391ae62 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -738,8 +738,11 @@ static void send_subscription(struct node *node)
 
 static int init_pmc(struct node *node, int domain_number)
 {
-       node->pmc = pmc_create(TRANS_UDS, "/var/run/phc2sys", 0,
-                               domain_number, 0, 1);
+       char uds_local[MAX_IFNAME_SIZE + 1];
+
+       snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
+                getpid());
+       node->pmc = pmc_create(TRANS_UDS, uds_local, 0, domain_number, 0, 1);
        if (!node->pmc) {
                pr_err("failed to create pmc");
                return -1;
diff --git a/pmc.8 b/pmc.8
index 0d36354..b113c78 100644
--- a/pmc.8
+++ b/pmc.8
@@ -73,7 +73,7 @@ Specify the boundary hops value in sent messages. The default 
is 1.
 Specify the domain number in sent messages. The default is 0.
 .TP
 .BI \-i " interface"
-Specify the network interface. The default is /var/run/pmc for the Unix Domain
+Specify the network interface. The default is /var/run/pmc.$pid for the Unix 
Domain
 Socket transport and eth0 for the other transports.
 .TP
 .BI \-s " uds-address"
diff --git a/pmc.c b/pmc.c
index 8cfae92..d58e190 100644
--- a/pmc.c
+++ b/pmc.c
@@ -700,7 +700,7 @@ static void usage(char *progname)
                " -d [num]  domain number, default 0\n"
                " -h        prints this message and exits\n"
                " -i [dev]  interface device to use, default 'eth0'\n"
-               "           for network and '/var/run/pmc' for UDS.\n"
+               "           for network and '/var/run/pmc.$pid' for UDS.\n"
                " -s [path] server address for UDS, default '/var/run/ptp4l'.\n"
                " -t [hex]  transport specific field, default 0x0\n"
                " -v        prints the software version and exits\n"
@@ -715,7 +715,7 @@ int main(int argc, char *argv[])
        char *progname;
        int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
        int ret = 0;
-       char line[1024], *command = NULL;
+       char line[1024], *command = NULL, uds_local[MAX_IFNAME_SIZE + 1];
        enum transport_type transport_type = TRANS_UDP_IPV4;
        UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
        struct ptp_message *msg;
@@ -781,7 +781,13 @@ int main(int argc, char *argv[])
        }
 
        if (!iface_name) {
-               iface_name = transport_type == TRANS_UDS ? "/var/run/pmc" : 
"eth0";
+               if (transport_type == TRANS_UDS) {
+                       snprintf(uds_local, sizeof(uds_local),
+                                "/var/run/pmc.%d", getpid());
+                       iface_name = uds_local;
+               } else {
+                       iface_name = "eth0";
+               }
        }
        if (optind < argc) {
                batch_mode = 1;
-- 
1.9.3


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to