Subject: Re: async I/O
To: Jan-Hinrich Fessel <oskar@zappa.unna.ping.de>
From: Tom I Helbekkmo <tih@Hamartun.Priv.NO>
List: current-users
Date: 09/03/1996 19:57:10
On Tue, 3 Sep 1996, Jan-Hinrich Fessel wrote:

> I still wonder if anyone has gotten a parse refclock running under NetBSD 

Here's what I wrote the last time you wondered...  :-)

| On Mon, 5 Feb 1996, Jan-Hinrich Fessel wrote:
| 
| > > xntpd 3.4y compiles on NetBSD 1.0 and later "out of the box".  I've used 
| > > it on the i386, hp300, and mac68k ports without trouble.
| > 
| > Anyone successfully using a parse refclock with that release?
| 
| I'm running the raw DCF77 variant under NetBSD/i386 1.1A almost right
| out of the box with no problems.  I use the clk_rawdcf.c PARSE driver
| to read the PPS signal from a cheap DCF77 receiver, level converted
| onto a serial port, and the only change needed was to the section for
| NetBSD in the file include/ntp_machine.h, which needs to do:
| 
| 	#define USE_FSETOWNCTTY
| 
| The bit of code that uses it is in xntpd/ntp_io.c, and this #define
| will cause it to set the serial port to be the controlling terminal
| before doing a fcntl(fd, F_SETOWN, pid) on it.
| 
| I would assume that this is a "wrong" solution -- it seems to me that
| this makes it impossible to run more than one PARSE clock at a time
| with the xntpd, and that's a silly limitation.  I just haven't found
| the time to look into it yet...  Meanwhile, I'm doing just fine with a
| single refclock, thank you!  :-)

...and here's part of Torsten Duwe's followup to that:

| You're correct. The problem is in /sys/kern/kern_descrip.c line 240-255:
| 
|         case F_SETOWN:
|                 if (fp->f_type == DTYPE_SOCKET) {
| [...]
|                 }
|                 return ((*fp->f_ops->fo_ioctl)
|                         (fp, (int)TIOCSPGRP, (caddr_t)&SCARG(uap, arg), p));
| 
|         case F_SETLKW:
| 
| F_SETOWN ought to be implemented instead of simply being mapped to setpgrp,
| because the latter is allowed only on the controlling terminal. A quick hack
| would be to simply lift this limitation, but - hey - this isn't Linux.
| 
| I tried to send-pr this, but it got lost during the sun-lamp shipment. Will
| some kind soul please take care of this ? Will another send-pr help ?
| 
| 	Torsten

I'm still running xntpd 3.4y with my one line modification (well,
since I'm rather a long way away from Mainflingen, I've also dropped
most of the syslog() calls), and it still works fine under 1.2_BETA.
In fact, I've just recompiled and restarted it just to be sure, and
there's no problem with it.

As far as I can tell, F_SETOWN is still just mapped to setpgrp, so the
limitation of just a single refclock (and the presence in ps(1) output
of the serial port you've got it on as the controlling terminal for
the xntpd process) is still there.

-tih
-- 
Tom Ivar Helbekkmo
tih@Hamartun.Priv.NO