Subject: Re: rwhod patch
To: Liam J. Foy <liamfoy@sepulcrum.org>
From: Peter Postma <peter@pointless.nl>
List: tech-userlevel
Date: 06/24/2005 13:08:11
On Thu, Jun 23, 2005 at 09:05:33PM +0100, Liam J. Foy wrote:
> Hey Guys,
> 
> 	The following patch is taken from OpenBSD Rev 1.15 on rwhod.c with my
> timing modifications. It can be seen at:
> 
> 	http://metawire.org/~liamfoy/rwhod.c.diff.n
> 
> Any comments? I have tested this out to the best of my ability(due to my
> network). I have also committed this patch into DragonFly BSD.
> 
> I have been running rwhod on 2.0.2 with that patch for a few days without any
> problems.
> 

I don't like the time changes, I think it's better to use the timer*
macros from sys/time.h.

+       send_host_information();
+       delta = AL_INTERVAL;

Make delta a struct timeval, and change AL_INTERVAL to... CHECK_INTERVAL?

+       gettimeofday(&now, NULL);
+       timeadd(&now, delta, &next);

Use timeradd here.

+       pfd[0].fd = s;
+       pfd[0].revents = POLLIN;

No, you must set 'events' to POLLIN but check 'revents' for POLLIN.

+               if (now.tv_sec > next.tv_sec) {

Use timercmp(&now, &next, >)

+                       timeadd(&now, delta, &next);

Use timeradd.

@@ -263,8 +313,7 @@
 int    alarmcount;

I would rename this variable, and maybe make it static in the function below
(and initialize!).

I think the rest is ok.

-- 
Peter Postma