Subject: Re: kern/30815: ntpd refclockio broken wrt/ SIGIO
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Frank Kardel <Frank.Kardel@Acrys.COM>
List: netbsd-bugs
Date: 07/25/2005 20:51:02
The following reply was made to PR kern/30815; it has been noted by GNATS.

From: Frank Kardel <Frank.Kardel@Acrys.COM>
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/30815: ntpd refclockio broken wrt/ SIGIO
Date: Mon, 25 Jul 2005 22:34:41 +0200

 Christos Zoulas wrote:
 
 >On Jul 23,  1:30pm, kardel@acm.org (kardel@acm.org) wrote:
 >-- Subject: kern/30815: ntpd refclockio broken wrt/ SIGIO
 >
 >| 	The recent relaxation to allow SIGIO on tty descriptors without
 >| 	requiring TIOCSCTTY is incomplete. Current version 1.9 of
 >| 	usr.sbin/ntp/include/config.h has USE_FSETOWNCTTY commented out.
 >| 	So ntpd doesn't aquire a CTTY. Fact is that currently TTY input
 >| 	does not cause a SIGIO to be delivered in this setup.
 >| 	ntpd pretends to run because of network SIGIOs, but ntpd is
 >|         unable to actually use a tty refclock as input on a TTY as
 >| 	input is batched in intervals of network caused SIGIOs.
 >| 
 >| 	So, currently ntpd refclock support is broken.
 >
 >Does the code set FIOASYNC?
 >
 >christos
 >
 >  
 >
 Yep. As you can see in the ktraces in 30815 the only difference id the 
 TIOCSCTTY call.
 The relevant section in libntp/iosignal.c is:
 
 #       if defined(TIOCSCTTY) && defined(USE_FSETOWNCTTY)
                 /*
                  * there are, however, always exceptions to the rules
                  * one is, that OSF accepts SETOWN on TTY fd's only, iff 
 they ar
 e
                  * CTTYs. SunOS and HPUX do not semm to have this 
 restriction.
                  * another question is: how can you do multiple SIGIO 
 from sever
 al
                  * ttys (as they all should be CTTYs), wondering...
                  *
                  * kd 95-07-16
                  */
                 if (ioctl(rio->fd, TIOCSCTTY, 0) == -1)
                 {
                         msyslog(LOG_ERR, "ioctl(TIOCSCTTY, 0) fails for 
 clock I/
 O: %m");
                         return 1;
                 }
 #       endif /* TIOCSCTTY && USE_FSETOWNCTTY */
 
                 if (fcntl(rio->fd, F_SETOWN, getpid()) == -1)
                 {
                         msyslog(LOG_ERR, "fcntl(F_SETOWN) fails for 
 clock I/O: %
 m");
                         return 1;
                 }
 
                 if (fcntl(rio->fd, F_SETFL, FNDELAY|FASYNC) < 0)
                 {
                         msyslog(LOG_ERR,
                                 "fcntl(FNDELAY|FASYNC) fails for clock 
 I/O: %m")
 ;
                         return 1;
                 }
                 return 0;
         }
 
 As you can see the CTTY is a long standing issue (see my comment from 
 19950716)
 and I'd be all too happy if it improves on NetBSD.
 
 I'll give 1.175 a shot - I just saw it coming in.
 
 Frank