Re: BUG REPORT: Time Drift in Event Module

[email protected] (Joshua N Pritikin) Sat, 3 Apr 2004 10:38:54 +0530
Newsgroups perl.loop
Message-ID <[email protected]>
On Fri, Apr 02, 2004 at 09:10:18PM -0500, Jerry D. Hedden wrote:
> I have determined that there is a definite bug in the Event module. 
> I have a fairly involved newsgroup reading application that I
> recently converted to using the Event module.  One of the timers is
> supposed to report the applications progress every 15 minutes on the
> quarter hour. 
> 
> my $now = time();
> my $prog_timer = Event->timer('at' => ($now + 900) - ($now % 900),
>                               'interval' => 900,
>                               'hard'     => 1,
>                               'cb'       => \&Progress);
> 
> However, as the program runs, these reports keep getting
> (cumulatively) later past the quarter hour.  When I put debug
> statements in the application to report the state of the reporting
> watcher, it shows that the time ('at' attribute) is correctly set to
> the quarter hour.

Yah, I can't see how 'at' could be calculated wrong.  See timer.c:35

> I've tried to go through the code to find the source of the
> discrepency, but haven't found where the problem lies yet.  I suspect
> that the module tries to keep track of time on its own without
> checking against the system clock.

Nope.

NVtime is implemented with time or gettimeofday (if you have
Time::HiRes).  See Event.pm:27

> As a result, small errors slowly
> accumulate causing events to be triggered later and later.  (For me,
> this error is accumulating at a rate of about 3 seconds every 15
> minutes of operation.)

Dunno.  The code is pretty simple and looks correct.

Have you tried NetServer::Portal?

-- 
A new cognitive theory of emotion, http://openheartlogic.org
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAbkbmqcqnlKSmC70RApn8AKCpbZc3b7zCWRFUgxT/49rrJwe/nQCfX+sE
h66+fdYnRFhknDTZcmSVKLE=
=ht8S
-----END PGP SIGNATURE-----