|
|
996523 |
commit 28865f91df96e83b28bb40565f12e62bd86e451f
|
|
|
996523 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
Date: Tue Jul 8 16:14:18 2014 +0200
|
|
|
996523 |
|
|
|
996523 |
phc2sys: Add option to set path to ptp4l UDS.
|
|
|
996523 |
|
|
|
996523 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
|
|
|
996523 |
diff --git a/phc2sys.8 b/phc2sys.8
|
|
|
996523 |
index a906fb3..c4fb6f6 100644
|
|
|
996523 |
--- a/phc2sys.8
|
|
|
996523 |
+++ b/phc2sys.8
|
|
|
996523 |
@@ -194,6 +194,10 @@ clock frequency (unless the
|
|
|
996523 |
.B \-S
|
|
|
996523 |
option is used).
|
|
|
996523 |
.TP
|
|
|
996523 |
+.BI \-z " uds-address"
|
|
|
996523 |
+Specifies the address of the server's UNIX domain socket.
|
|
|
996523 |
+The default is /var/run/ptp4l.
|
|
|
996523 |
+.TP
|
|
|
996523 |
.BI \-l " print-level"
|
|
|
996523 |
Set the maximum syslog level of messages which should be printed or sent to
|
|
|
996523 |
the system logger. The default is 6 (LOG_INFO).
|
|
|
996523 |
diff --git a/phc2sys.c b/phc2sys.c
|
|
|
996523 |
index 7815a8e..418f4ac 100644
|
|
|
996523 |
--- a/phc2sys.c
|
|
|
996523 |
+++ b/phc2sys.c
|
|
|
996523 |
@@ -53,6 +53,7 @@
|
|
|
996523 |
#include "stats.h"
|
|
|
996523 |
#include "sysoff.h"
|
|
|
996523 |
#include "tlv.h"
|
|
|
996523 |
+#include "uds.h"
|
|
|
996523 |
#include "util.h"
|
|
|
996523 |
#include "version.h"
|
|
|
996523 |
|
|
|
996523 |
@@ -1158,6 +1159,7 @@ static void usage(char *progname)
|
|
|
996523 |
" -u [num] number of clock updates in summary stats (0)\n"
|
|
|
996523 |
" -n [num] domain number (0)\n"
|
|
|
996523 |
" -x apply leap seconds by servo instead of kernel\n"
|
|
|
996523 |
+ " -z [path] server address for UDS (/var/run/ptp4l)\n"
|
|
|
996523 |
" -l [num] set the logging level to 'num' (6)\n"
|
|
|
996523 |
" -m print messages to stdout\n"
|
|
|
996523 |
" -q do not print messages to the syslog\n"
|
|
|
996523 |
@@ -1192,7 +1194,7 @@ int main(int argc, char *argv[])
|
|
|
996523 |
progname = strrchr(argv[0], '/');
|
|
|
996523 |
progname = progname ? 1+progname : argv[0];
|
|
|
996523 |
while (EOF != (c = getopt(argc, argv,
|
|
|
996523 |
- "arc:d:s:E:P:I:S:F:R:N:O:L:i:u:wn:xl:mqvh"))) {
|
|
|
996523 |
+ "arc:d:s:E:P:I:S:F:R:N:O:L:i:u:wn:xz:l:mqvh"))) {
|
|
|
996523 |
switch (c) {
|
|
|
996523 |
case 'a':
|
|
|
996523 |
autocfg = 1;
|
|
|
996523 |
@@ -1285,6 +1287,14 @@ int main(int argc, char *argv[])
|
|
|
996523 |
case 'x':
|
|
|
996523 |
node.kernel_leap = 0;
|
|
|
996523 |
break;
|
|
|
996523 |
+ case 'z':
|
|
|
996523 |
+ if (strlen(optarg) > MAX_IFNAME_SIZE) {
|
|
|
996523 |
+ fprintf(stderr, "path %s too long, max is %d\n",
|
|
|
996523 |
+ optarg, MAX_IFNAME_SIZE);
|
|
|
996523 |
+ return -1;
|
|
|
996523 |
+ }
|
|
|
996523 |
+ strncpy(uds_path, optarg, MAX_IFNAME_SIZE);
|
|
|
996523 |
+ break;
|
|
|
996523 |
case 'l':
|
|
|
996523 |
if (get_arg_val_i(c, optarg, &print_level,
|
|
|
996523 |
PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
|
|
|
996523 |
|
|
|
996523 |
commit 2423357754ae7d64d844fc064c72b8d27adf40c4
|
|
|
996523 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
Date: Tue Jul 8 16:14:19 2014 +0200
|
|
|
996523 |
|
|
|
996523 |
Remove socket when closing UDS transport.
|
|
|
996523 |
|
|
|
996523 |
[RC: added cast to sockaddr to avoid compiler warning. ]
|
|
|
996523 |
|
|
|
996523 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
|
|
|
996523 |
diff --git a/uds.c b/uds.c
|
|
|
996523 |
index e98e32c..97edb97 100644
|
|
|
996523 |
--- a/uds.c
|
|
|
996523 |
+++ b/uds.c
|
|
|
996523 |
@@ -42,6 +42,14 @@ struct uds {
|
|
|
996523 |
|
|
|
996523 |
static int uds_close(struct transport *t, struct fdarray *fda)
|
|
|
996523 |
{
|
|
|
996523 |
+ struct sockaddr_un sa;
|
|
|
996523 |
+ socklen_t len = sizeof(sa);
|
|
|
996523 |
+
|
|
|
996523 |
+ if (!getsockname(fda->fd[FD_GENERAL], (struct sockaddr *) &sa, &len) &&
|
|
|
996523 |
+ sa.sun_family == AF_LOCAL) {
|
|
|
996523 |
+ unlink(sa.sun_path);
|
|
|
996523 |
+ }
|
|
|
996523 |
+
|
|
|
996523 |
close(fda->fd[FD_GENERAL]);
|
|
|
996523 |
return 0;
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
commit ca637b2067ae78c9830c38bb5e9a659255b1a4a2
|
|
|
996523 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
Date: Tue Jul 8 16:14:20 2014 +0200
|
|
|
996523 |
|
|
|
996523 |
Move signal handling to util.c.
|
|
|
996523 |
|
|
|
996523 |
This will be useful in phc2sys and pmc.
|
|
|
996523 |
|
|
|
996523 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
|
|
|
996523 |
diff --git a/ptp4l.c b/ptp4l.c
|
|
|
996523 |
index 25270c6..5080a79 100644
|
|
|
996523 |
--- a/ptp4l.c
|
|
|
996523 |
+++ b/ptp4l.c
|
|
|
996523 |
@@ -18,7 +18,6 @@
|
|
|
996523 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
996523 |
*/
|
|
|
996523 |
#include <limits.h>
|
|
|
996523 |
-#include <signal.h>
|
|
|
996523 |
#include <stdio.h>
|
|
|
996523 |
#include <stdlib.h>
|
|
|
996523 |
#include <string.h>
|
|
|
996523 |
@@ -40,8 +39,6 @@
|
|
|
996523 |
|
|
|
996523 |
int assume_two_step = 0;
|
|
|
996523 |
|
|
|
996523 |
-static int running = 1;
|
|
|
996523 |
-
|
|
|
996523 |
static struct config cfg_settings = {
|
|
|
996523 |
.dds = {
|
|
|
996523 |
.dds = {
|
|
|
996523 |
@@ -131,12 +128,6 @@ static struct config cfg_settings = {
|
|
|
996523 |
.cfg_ignore = 0,
|
|
|
996523 |
};
|
|
|
996523 |
|
|
|
996523 |
-static void handle_int_quit_term(int s)
|
|
|
996523 |
-{
|
|
|
996523 |
- pr_notice("caught signal %d", s);
|
|
|
996523 |
- running = 0;
|
|
|
996523 |
-}
|
|
|
996523 |
-
|
|
|
996523 |
static void usage(char *progname)
|
|
|
996523 |
{
|
|
|
996523 |
fprintf(stderr,
|
|
|
996523 |
@@ -184,18 +175,8 @@ int main(int argc, char *argv[])
|
|
|
996523 |
struct defaultDS *ds = &cfg_settings.dds.dds;
|
|
|
996523 |
int phc_index = -1, required_modes = 0;
|
|
|
996523 |
|
|
|
996523 |
- if (SIG_ERR == signal(SIGINT, handle_int_quit_term)) {
|
|
|
996523 |
- fprintf(stderr, "cannot handle SIGINT\n");
|
|
|
996523 |
+ if (handle_term_signals())
|
|
|
996523 |
return -1;
|
|
|
996523 |
- }
|
|
|
996523 |
- if (SIG_ERR == signal(SIGQUIT, handle_int_quit_term)) {
|
|
|
996523 |
- fprintf(stderr, "cannot handle SIGQUIT\n");
|
|
|
996523 |
- return -1;
|
|
|
996523 |
- }
|
|
|
996523 |
- if (SIG_ERR == signal(SIGTERM, handle_int_quit_term)) {
|
|
|
996523 |
- fprintf(stderr, "cannot handle SIGTERM\n");
|
|
|
996523 |
- return -1;
|
|
|
996523 |
- }
|
|
|
996523 |
|
|
|
996523 |
/* Set fault timeouts to a default value */
|
|
|
996523 |
for (i = 0; i < FT_CNT; i++) {
|
|
|
996523 |
@@ -404,7 +385,7 @@ int main(int argc, char *argv[])
|
|
|
996523 |
return -1;
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
- while (running) {
|
|
|
996523 |
+ while (is_running()) {
|
|
|
996523 |
if (clock_poll(clock))
|
|
|
996523 |
break;
|
|
|
996523 |
}
|
|
|
996523 |
diff --git a/util.c b/util.c
|
|
|
996523 |
index 1e86040..ae66bb1 100644
|
|
|
996523 |
--- a/util.c
|
|
|
996523 |
+++ b/util.c
|
|
|
996523 |
@@ -17,11 +17,13 @@
|
|
|
996523 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
996523 |
*/
|
|
|
996523 |
#include <errno.h>
|
|
|
996523 |
+#include <signal.h>
|
|
|
996523 |
#include <stdio.h>
|
|
|
996523 |
#include <stdlib.h>
|
|
|
996523 |
#include <string.h>
|
|
|
996523 |
|
|
|
996523 |
#include "address.h"
|
|
|
996523 |
+#include "print.h"
|
|
|
996523 |
#include "sk.h"
|
|
|
996523 |
#include "util.h"
|
|
|
996523 |
|
|
|
996523 |
@@ -29,6 +31,8 @@
|
|
|
996523 |
#define NS_PER_HOUR (3600 * NS_PER_SEC)
|
|
|
996523 |
#define NS_PER_DAY (24 * NS_PER_HOUR)
|
|
|
996523 |
|
|
|
996523 |
+static int running = 1;
|
|
|
996523 |
+
|
|
|
996523 |
const char *ps_str[] = {
|
|
|
996523 |
"NONE",
|
|
|
996523 |
"INITIALIZING",
|
|
|
996523 |
@@ -311,3 +315,31 @@ int get_arg_val_d(int op, const char *optarg, double *val,
|
|
|
996523 |
}
|
|
|
996523 |
return 0;
|
|
|
996523 |
}
|
|
|
996523 |
+
|
|
|
996523 |
+static void handle_int_quit_term(int s)
|
|
|
996523 |
+{
|
|
|
996523 |
+ pr_notice("caught signal %d", s);
|
|
|
996523 |
+ running = 0;
|
|
|
996523 |
+}
|
|
|
996523 |
+
|
|
|
996523 |
+int handle_term_signals(void)
|
|
|
996523 |
+{
|
|
|
996523 |
+ if (SIG_ERR == signal(SIGINT, handle_int_quit_term)) {
|
|
|
996523 |
+ fprintf(stderr, "cannot handle SIGINT\n");
|
|
|
996523 |
+ return -1;
|
|
|
996523 |
+ }
|
|
|
996523 |
+ if (SIG_ERR == signal(SIGQUIT, handle_int_quit_term)) {
|
|
|
996523 |
+ fprintf(stderr, "cannot handle SIGQUIT\n");
|
|
|
996523 |
+ return -1;
|
|
|
996523 |
+ }
|
|
|
996523 |
+ if (SIG_ERR == signal(SIGTERM, handle_int_quit_term)) {
|
|
|
996523 |
+ fprintf(stderr, "cannot handle SIGTERM\n");
|
|
|
996523 |
+ return -1;
|
|
|
996523 |
+ }
|
|
|
996523 |
+ return 0;
|
|
|
996523 |
+}
|
|
|
996523 |
+
|
|
|
996523 |
+int is_running(void)
|
|
|
996523 |
+{
|
|
|
996523 |
+ return running;
|
|
|
996523 |
+}
|
|
|
996523 |
diff --git a/util.h b/util.h
|
|
|
996523 |
index 3fae51c..cf05e49 100644
|
|
|
996523 |
--- a/util.h
|
|
|
996523 |
+++ b/util.h
|
|
|
996523 |
@@ -212,4 +212,18 @@ int get_arg_val_ui(int op, const char *optarg, unsigned int *val,
|
|
|
996523 |
int get_arg_val_d(int op, const char *optarg, double *val,
|
|
|
996523 |
double min, double max);
|
|
|
996523 |
|
|
|
996523 |
+/**
|
|
|
996523 |
+ * Setup a handler for terminating signals (SIGINT, SIGQUIT, SIGTERM).
|
|
|
996523 |
+ *
|
|
|
996523 |
+ * @return 0 on success, -1 on error.
|
|
|
996523 |
+ */
|
|
|
996523 |
+int handle_term_signals(void);
|
|
|
996523 |
+
|
|
|
996523 |
+/**
|
|
|
996523 |
+ * Check if a terminating signal was received.
|
|
|
996523 |
+ *
|
|
|
996523 |
+ * @return 1 if no terminating signal was received, 0 otherwise.
|
|
|
996523 |
+ */
|
|
|
996523 |
+int is_running(void);
|
|
|
996523 |
+
|
|
|
996523 |
#endif
|
|
|
996523 |
|
|
|
996523 |
commit 30841a68495b5e9ba11ff4b056c4a79b0b73d14a
|
|
|
996523 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
Date: Tue Jul 8 16:14:21 2014 +0200
|
|
|
996523 |
|
|
|
996523 |
Close client UDS transport before exit.
|
|
|
996523 |
|
|
|
996523 |
In pmc and phc2sys handle terminating signals and close the UDS
|
|
|
996523 |
transport before exit to remove the sockets in /var/run.
|
|
|
996523 |
|
|
|
996523 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
|
|
|
996523 |
diff --git a/phc2sys.c b/phc2sys.c
|
|
|
996523 |
index 418f4ac..3039e51 100644
|
|
|
996523 |
--- a/phc2sys.c
|
|
|
996523 |
+++ b/phc2sys.c
|
|
|
996523 |
@@ -526,7 +526,7 @@ static int do_pps_loop(struct node *node, struct clock *clock, int fd)
|
|
|
996523 |
enable_pps_output(node->master->clkid);
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
- while (1) {
|
|
|
996523 |
+ while (is_running()) {
|
|
|
996523 |
if (!read_pps(fd, &pps_offset, &pps_ts)) {
|
|
|
996523 |
continue;
|
|
|
996523 |
}
|
|
|
996523 |
@@ -570,7 +570,7 @@ static int do_loop(struct node *node, int subscriptions)
|
|
|
996523 |
interval.tv_sec = node->phc_interval;
|
|
|
996523 |
interval.tv_nsec = (node->phc_interval - interval.tv_sec) * 1e9;
|
|
|
996523 |
|
|
|
996523 |
- while (1) {
|
|
|
996523 |
+ while (is_running()) {
|
|
|
996523 |
clock_nanosleep(CLOCK_MONOTONIC, 0, &interval, NULL);
|
|
|
996523 |
if (update_pmc(node, subscriptions) < 0)
|
|
|
996523 |
continue;
|
|
|
996523 |
@@ -611,7 +611,7 @@ static int do_loop(struct node *node, int subscriptions)
|
|
|
996523 |
update_clock(node, clock, offset, ts, delay);
|
|
|
996523 |
}
|
|
|
996523 |
}
|
|
|
996523 |
- return 0; /* unreachable */
|
|
|
996523 |
+ return 0;
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
static int check_clock_identity(struct node *node, struct ptp_message *msg)
|
|
|
996523 |
@@ -1187,6 +1187,8 @@ int main(int argc, char *argv[])
|
|
|
996523 |
.kernel_leap = 1,
|
|
|
996523 |
};
|
|
|
996523 |
|
|
|
996523 |
+ handle_term_signals();
|
|
|
996523 |
+
|
|
|
996523 |
configured_pi_kp = KP;
|
|
|
996523 |
configured_pi_ki = KI;
|
|
|
996523 |
|
|
|
996523 |
@@ -1349,7 +1351,8 @@ int main(int argc, char *argv[])
|
|
|
996523 |
return -1;
|
|
|
996523 |
if (auto_init_ports(&node, rt) < 0)
|
|
|
996523 |
return -1;
|
|
|
996523 |
- return do_loop(&node, 1);
|
|
|
996523 |
+ r = do_loop(&node, 1);
|
|
|
996523 |
+ goto end;
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
src = clock_add(&node, src_name);
|
|
|
996523 |
@@ -1377,14 +1380,16 @@ int main(int argc, char *argv[])
|
|
|
996523 |
goto bad_usage;
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
+ r = -1;
|
|
|
996523 |
+
|
|
|
996523 |
if (wait_sync) {
|
|
|
996523 |
if (init_pmc(&node, domain_number))
|
|
|
996523 |
- return -1;
|
|
|
996523 |
+ goto end;
|
|
|
996523 |
|
|
|
996523 |
- while (1) {
|
|
|
996523 |
+ while (is_running()) {
|
|
|
996523 |
r = run_pmc_wait_sync(&node, 1000);
|
|
|
996523 |
if (r < 0)
|
|
|
996523 |
- return -1;
|
|
|
996523 |
+ goto end;
|
|
|
996523 |
if (r > 0)
|
|
|
996523 |
break;
|
|
|
996523 |
else
|
|
|
996523 |
@@ -1395,7 +1400,7 @@ int main(int argc, char *argv[])
|
|
|
996523 |
r = run_pmc_get_utc_offset(&node, 1000);
|
|
|
996523 |
if (r <= 0) {
|
|
|
996523 |
pr_err("failed to get UTC offset");
|
|
|
996523 |
- return -1;
|
|
|
996523 |
+ goto end;
|
|
|
996523 |
}
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
@@ -1409,11 +1414,16 @@ int main(int argc, char *argv[])
|
|
|
996523 |
/* only one destination clock allowed with PPS until we
|
|
|
996523 |
* implement a mean to specify PTP port to PPS mapping */
|
|
|
996523 |
servo_sync_interval(dst->servo, 1.0);
|
|
|
996523 |
- return do_pps_loop(&node, dst, pps_fd);
|
|
|
996523 |
+ r = do_pps_loop(&node, dst, pps_fd);
|
|
|
996523 |
+ } else {
|
|
|
996523 |
+ r = do_loop(&node, 0);
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
- return do_loop(&node, 0);
|
|
|
996523 |
+end:
|
|
|
996523 |
+ if (node.pmc)
|
|
|
996523 |
+ close_pmc(&node);
|
|
|
996523 |
|
|
|
996523 |
+ return r;
|
|
|
996523 |
bad_usage:
|
|
|
996523 |
usage(progname);
|
|
|
996523 |
return -1;
|
|
|
996523 |
diff --git a/pmc.c b/pmc.c
|
|
|
996523 |
index ba06293..8cfae92 100644
|
|
|
996523 |
--- a/pmc.c
|
|
|
996523 |
+++ b/pmc.c
|
|
|
996523 |
@@ -714,6 +714,7 @@ int main(int argc, char *argv[])
|
|
|
996523 |
const char *iface_name = NULL;
|
|
|
996523 |
char *progname;
|
|
|
996523 |
int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
|
|
|
996523 |
+ int ret = 0;
|
|
|
996523 |
char line[1024], *command = NULL;
|
|
|
996523 |
enum transport_type transport_type = TRANS_UDP_IPV4;
|
|
|
996523 |
UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
|
|
|
996523 |
@@ -721,6 +722,8 @@ int main(int argc, char *argv[])
|
|
|
996523 |
#define N_FD 2
|
|
|
996523 |
struct pollfd pollfd[N_FD];
|
|
|
996523 |
|
|
|
996523 |
+ handle_term_signals();
|
|
|
996523 |
+
|
|
|
996523 |
/* Process the command line arguments. */
|
|
|
996523 |
progname = strrchr(argv[0], '/');
|
|
|
996523 |
progname = progname ? 1+progname : argv[0];
|
|
|
996523 |
@@ -798,7 +801,7 @@ int main(int argc, char *argv[])
|
|
|
996523 |
pollfd[0].fd = batch_mode ? -1 : STDIN_FILENO;
|
|
|
996523 |
pollfd[1].fd = pmc_get_transport_fd(pmc);
|
|
|
996523 |
|
|
|
996523 |
- while (1) {
|
|
|
996523 |
+ while (is_running()) {
|
|
|
996523 |
if (batch_mode && !command) {
|
|
|
996523 |
if (optind < argc) {
|
|
|
996523 |
command = argv[optind++];
|
|
|
996523 |
@@ -823,7 +826,8 @@ int main(int argc, char *argv[])
|
|
|
996523 |
continue;
|
|
|
996523 |
} else {
|
|
|
996523 |
pr_emerg("poll failed");
|
|
|
996523 |
- return -1;
|
|
|
996523 |
+ ret = -1;
|
|
|
996523 |
+ break;
|
|
|
996523 |
}
|
|
|
996523 |
} else if (!cnt) {
|
|
|
996523 |
break;
|
|
|
996523 |
@@ -866,5 +870,5 @@ int main(int argc, char *argv[])
|
|
|
996523 |
|
|
|
996523 |
pmc_destroy(pmc);
|
|
|
996523 |
msg_cleanup();
|
|
|
996523 |
- return 0;
|
|
|
996523 |
+ return ret;
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
commit 1773d21f26eb1aa2da0645af116d6ce27591a9cc
|
|
|
996523 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
Date: Tue Jul 8 16:14:22 2014 +0200
|
|
|
996523 |
|
|
|
996523 |
Append PID to client UDS paths.
|
|
|
996523 |
|
|
|
996523 |
This allows running multiple phc2sys and pmc instances at the same time.
|
|
|
996523 |
|
|
|
996523 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
|
|
|
996523 |
diff --git a/phc2sys.c b/phc2sys.c
|
|
|
996523 |
index 3039e51..391ae62 100644
|
|
|
996523 |
--- a/phc2sys.c
|
|
|
996523 |
+++ b/phc2sys.c
|
|
|
996523 |
@@ -738,8 +738,11 @@ static void send_subscription(struct node *node)
|
|
|
996523 |
|
|
|
996523 |
static int init_pmc(struct node *node, int domain_number)
|
|
|
996523 |
{
|
|
|
996523 |
- node->pmc = pmc_create(TRANS_UDS, "/var/run/phc2sys", 0,
|
|
|
996523 |
- domain_number, 0, 1);
|
|
|
996523 |
+ char uds_local[MAX_IFNAME_SIZE + 1];
|
|
|
996523 |
+
|
|
|
996523 |
+ snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
|
|
|
996523 |
+ getpid());
|
|
|
996523 |
+ node->pmc = pmc_create(TRANS_UDS, uds_local, 0, domain_number, 0, 1);
|
|
|
996523 |
if (!node->pmc) {
|
|
|
996523 |
pr_err("failed to create pmc");
|
|
|
996523 |
return -1;
|
|
|
996523 |
diff --git a/pmc.8 b/pmc.8
|
|
|
996523 |
index 0d36354..b113c78 100644
|
|
|
996523 |
--- a/pmc.8
|
|
|
996523 |
+++ b/pmc.8
|
|
|
996523 |
@@ -73,7 +73,7 @@ Specify the boundary hops value in sent messages. The default is 1.
|
|
|
996523 |
Specify the domain number in sent messages. The default is 0.
|
|
|
996523 |
.TP
|
|
|
996523 |
.BI \-i " interface"
|
|
|
996523 |
-Specify the network interface. The default is /var/run/pmc for the Unix Domain
|
|
|
996523 |
+Specify the network interface. The default is /var/run/pmc.$pid for the Unix Domain
|
|
|
996523 |
Socket transport and eth0 for the other transports.
|
|
|
996523 |
.TP
|
|
|
996523 |
.BI \-s " uds-address"
|
|
|
996523 |
diff --git a/pmc.c b/pmc.c
|
|
|
996523 |
index 8cfae92..d58e190 100644
|
|
|
996523 |
--- a/pmc.c
|
|
|
996523 |
+++ b/pmc.c
|
|
|
996523 |
@@ -700,7 +700,7 @@ static void usage(char *progname)
|
|
|
996523 |
" -d [num] domain number, default 0\n"
|
|
|
996523 |
" -h prints this message and exits\n"
|
|
|
996523 |
" -i [dev] interface device to use, default 'eth0'\n"
|
|
|
996523 |
- " for network and '/var/run/pmc' for UDS.\n"
|
|
|
996523 |
+ " for network and '/var/run/pmc.$pid' for UDS.\n"
|
|
|
996523 |
" -s [path] server address for UDS, default '/var/run/ptp4l'.\n"
|
|
|
996523 |
" -t [hex] transport specific field, default 0x0\n"
|
|
|
996523 |
" -v prints the software version and exits\n"
|
|
|
996523 |
@@ -715,7 +715,7 @@ int main(int argc, char *argv[])
|
|
|
996523 |
char *progname;
|
|
|
996523 |
int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
|
|
|
996523 |
int ret = 0;
|
|
|
996523 |
- char line[1024], *command = NULL;
|
|
|
996523 |
+ char line[1024], *command = NULL, uds_local[MAX_IFNAME_SIZE + 1];
|
|
|
996523 |
enum transport_type transport_type = TRANS_UDP_IPV4;
|
|
|
996523 |
UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
|
|
|
996523 |
struct ptp_message *msg;
|
|
|
996523 |
@@ -781,7 +781,13 @@ int main(int argc, char *argv[])
|
|
|
996523 |
}
|
|
|
996523 |
|
|
|
996523 |
if (!iface_name) {
|
|
|
996523 |
- iface_name = transport_type == TRANS_UDS ? "/var/run/pmc" : "eth0";
|
|
|
996523 |
+ if (transport_type == TRANS_UDS) {
|
|
|
996523 |
+ snprintf(uds_local, sizeof(uds_local),
|
|
|
996523 |
+ "/var/run/pmc.%d", getpid());
|
|
|
996523 |
+ iface_name = uds_local;
|
|
|
996523 |
+ } else {
|
|
|
996523 |
+ iface_name = "eth0";
|
|
|
996523 |
+ }
|
|
|
996523 |
}
|
|
|
996523 |
if (optind < argc) {
|
|
|
996523 |
batch_mode = 1;
|
|
|
996523 |
commit aa24ba58e1901f9397624665c1f19a2432e426d0
|
|
|
996523 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
Date: Fri Oct 3 14:13:49 2014 +0200
|
|
|
996523 |
|
|
|
996523 |
Don't print messages in signal handler.
|
|
|
996523 |
|
|
|
996523 |
Only reentrant functions should be called here.
|
|
|
996523 |
|
|
|
996523 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
996523 |
|
|
|
996523 |
diff --git a/util.c b/util.c
|
|
|
996523 |
index ae66bb1..cb428b1 100644
|
|
|
996523 |
--- a/util.c
|
|
|
996523 |
+++ b/util.c
|
|
|
996523 |
@@ -318,7 +318,6 @@ int get_arg_val_d(int op, const char *optarg, double *val,
|
|
|
996523 |
|
|
|
996523 |
static void handle_int_quit_term(int s)
|
|
|
996523 |
{
|
|
|
996523 |
- pr_notice("caught signal %d", s);
|
|
|
996523 |
running = 0;
|
|
|
996523 |
}
|
|
|
996523 |
|