Append PID to client UDS paths.

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

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2014-07-08 16:14:22 +02:00 committed by Richard Cochran
parent 30841a6849
commit 1773d21f26
3 changed files with 15 additions and 6 deletions

View File

@ -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;

2
pmc.8
View File

@ -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"

12
pmc.c
View File

@ -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;