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>
This commit is contained in:
		
							parent
							
								
									30841a6849
								
							
						
					
					
						commit
						1773d21f26
					
				@ -738,8 +738,11 @@ static void send_subscription(struct node *node)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int init_pmc(struct node *node, int domain_number)
 | 
					static int init_pmc(struct node *node, int domain_number)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	node->pmc = pmc_create(TRANS_UDS, "/var/run/phc2sys", 0,
 | 
						char uds_local[MAX_IFNAME_SIZE + 1];
 | 
				
			||||||
				domain_number, 0, 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) {
 | 
						if (!node->pmc) {
 | 
				
			||||||
		pr_err("failed to create pmc");
 | 
							pr_err("failed to create pmc");
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								pmc.8
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								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.
 | 
					Specify the domain number in sent messages. The default is 0.
 | 
				
			||||||
.TP
 | 
					.TP
 | 
				
			||||||
.BI \-i " interface"
 | 
					.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.
 | 
					Socket transport and eth0 for the other transports.
 | 
				
			||||||
.TP
 | 
					.TP
 | 
				
			||||||
.BI \-s " uds-address"
 | 
					.BI \-s " uds-address"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								pmc.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								pmc.c
									
									
									
									
									
								
							@ -700,7 +700,7 @@ static void usage(char *progname)
 | 
				
			|||||||
		" -d [num]  domain number, default 0\n"
 | 
							" -d [num]  domain number, default 0\n"
 | 
				
			||||||
		" -h        prints this message and exits\n"
 | 
							" -h        prints this message and exits\n"
 | 
				
			||||||
		" -i [dev]  interface device to use, default 'eth0'\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"
 | 
							" -s [path] server address for UDS, default '/var/run/ptp4l'.\n"
 | 
				
			||||||
		" -t [hex]  transport specific field, default 0x0\n"
 | 
							" -t [hex]  transport specific field, default 0x0\n"
 | 
				
			||||||
		" -v        prints the software version and exits\n"
 | 
							" -v        prints the software version and exits\n"
 | 
				
			||||||
@ -715,7 +715,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
	char *progname;
 | 
						char *progname;
 | 
				
			||||||
	int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
 | 
						int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
 | 
				
			||||||
	int ret = 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;
 | 
						enum transport_type transport_type = TRANS_UDP_IPV4;
 | 
				
			||||||
	UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
 | 
						UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
 | 
				
			||||||
	struct ptp_message *msg;
 | 
						struct ptp_message *msg;
 | 
				
			||||||
@ -781,7 +781,13 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!iface_name) {
 | 
						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) {
 | 
						if (optind < argc) {
 | 
				
			||||||
		batch_mode = 1;
 | 
							batch_mode = 1;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user