[LinuxPPS] Re: Can't configure multiple pps sources in ntpd
Rodolfo Giometti
giometti at linux.it
Sun Oct 22 23:54:07 CEST 2006
On Sat, Oct 21, 2006 at 06:49:35AM -0400, linux at horizon.com wrote:
> I got two GPS clocks connected up to my server, with PPS on DCD on
> both /dev/ttyS0 and /dev/ttyS1 and found a bug...
>
> If you try to configure two PPS time sources in ntp.conf, the second call
> to time_pps_findsource() tries to create a second AF_NETLINK socket,
> assigns it the same nl_pid, and bind() fails with EADDRINUSE. I think
> the API is supposed to let you call that function more than once.
Please, try this patch:
diff --git a/include/linux/timepps.h b/include/linux/timepps.h
index 93fe2bb..915fb02 100644
--- a/include/linux/timepps.h
+++ b/include/linux/timepps.h
@@ -266,7 +266,7 @@ static __inline int time_pps_create(int
/* Bind the socket with the source address */
memset(&src_addr, 0, sizeof(src_addr));
src_addr.nl_family = AF_NETLINK;
- src_addr.nl_pid = getpid(); /* self PID as unique ID */
+ src_addr.nl_pid = 0; /* ask kernel to choose an unique ID */
src_addr.nl_groups = 0; /* not in mcast groups */
ret = bind(handle->socket, (struct sockaddr *) &src_addr, sizeof(src_addr));
if (ret < 0) {
@@ -429,7 +429,7 @@ static __inline int time_pps_findsource(
/* Bind the socket with the source address */
memset(&src_addr, 0, sizeof(src_addr));
src_addr.nl_family = AF_NETLINK;
- src_addr.nl_pid = getpid(); /* self PID as unique ID */
+ src_addr.nl_pid = 0; /* ask kernel to choose an unique ID */
src_addr.nl_groups = 0; /* not in mcast groups */
ret = bind(sock, (struct sockaddr *) &src_addr, sizeof(src_addr));
if (ret < 0) {
@@ -487,7 +487,7 @@ static __inline int time_pps_findpath(ch
/* Bind the socket with the source address */
memset(&src_addr, 0, sizeof(src_addr));
src_addr.nl_family = AF_NETLINK;
- src_addr.nl_pid = getpid(); /* self PID as unique ID */
+ src_addr.nl_pid = 0; /* ask kernel to choose an unique ID */
src_addr.nl_groups = 0; /* not in mcast groups */
ret = bind(sock, (struct sockaddr *) &src_addr, sizeof(src_addr));
if (ret < 0) {
Ciao,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti at enneenne.com
Linux Device Driver giometti at gnudd.com
Embedded Systems giometti at linux.it
UNIX programming phone: +39 349 2432127
More information about the LinuxPPS
mailing list