Bug in Event-0.81?

[email protected] (Peter Lombard)
Newsgroups perl.loop
Message-ID <[email protected]>
I believe I have found a small bug in Event-0.81 that causes the event loop to
use too much CPU time. This is with perl 5.6.0 on Solaris 2.6.

The symptoms I see are: when a timer comes due for action, Event spends one
second doing a tight loop calling poll() with zero timeout before it executes
the callback of the of the timer.

The problem appears to be in pe_timeables_check() in c/timeable.c. Here's the
context diff: 
*** timeable.c  Mon Apr 16 08:12:15 2001
--- timeable.c-ORIG     Tue Jun 13 08:24:24 2000
***************
*** 19,25 ****
      pe_timeable *tm = (pe_timeable*) Timeables.ring.next;
      double now = NVtime();
      /*  warn("timeables at %.2f\n", now); db_show_timeables();/**/
!     while (tm->ring.self && tm->at <= now) {
        pe_watcher *ev = (pe_watcher*) tm->ring.self;
        pe_timeable *next = (pe_timeable*) tm->ring.next;
        D_TIMEABLE({
--- 19,25 ----
      pe_timeable *tm = (pe_timeable*) Timeables.ring.next;
      double now = NVtime();
      /*  warn("timeables at %.2f\n", now); db_show_timeables();/**/
!     while (tm->ring.self && tm->at < now) {
        pe_watcher *ev = (pe_watcher*) tm->ring.self;
        pe_timeable *next = (pe_timeable*) tm->ring.next;
        D_TIMEABLE({


With this change, Event executes the timer's callback as soon as it is due,
without doing a bunch of poll() calls. But I am not certain that this doesn't
break something else in Event; this C in perl is pretty new to me!

-- 
Pete Lombard
Seismological Laboratory       
215 McCone Hall
University of California
Berkeley, CA 94720-4760

[email protected]
(510) 642-0073
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.