Re: Bug in Event-0.81?

[email protected] (Joshua Pritikin)
Newsgroups perl.loop
Message-ID <[email protected]>
Peter Lombard wrote:
>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!

That looks like the correct fix.

Unfortunately i won't be able to upload a new version
of Event to CPAN for at least a few weeks because i
am travelling around India.


_____________________________________________________________
Thank you for choosing LinuxQuestions.
http://www.linuxquestions.org
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.