----- Forwarded message from [EMAIL PROTECTED] -----

Date: Wed, 26 Apr 2000 22:19:21 +0200
Subject: CPAN Upload: JPRIT/Event-0.76.tar.gz
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED],
    [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]

The uploaded file

    Event-0.76.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/JPRIT/Event-0.76.tar.gz
  size: 148425 bytes
   md5: d6c1cc491093882e8f8e7db05166328c

No action is required on your part
Request entered by: JPRIT (Joshua N. Pritikin)
Request entered on: Wed, 26 Apr 2000 20:19:08 GMT
Request completed:  Wed, 26 Apr 2000 20:19:21 GMT

        Virtually Yours,
        Id: paused,v 1.68 1999/10/22 14:39:12 k Exp k 

# This is a patch for Event-0.75 to update it to Event-0.76
# 
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####

#### Patch data follows ####
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/ChangeLog' 
'/usr/tmp/mp5304.d/new/Event-0.76/ChangeLog'
Index: ./ChangeLog
--- ./ChangeLog Mon Apr 24 09:43:08 2000
+++ ./ChangeLog Wed Apr 26 13:13:37 2000
@@ -1,3 +1,16 @@
+2000-04-26  Joshua Pritikin  <[EMAIL PROTECTED]>
+
+       * Release 0.76.
+
+       * Fixed a horribly subtle bug in the handling of reentrant
+       INVOKE1-style watchers (e.g. a timer) in nested loops.  Added
+       test.  This change also removes at least one conditional from a
+       hot code path.
+
+2000-04-25  Joshua Pritikin  <[EMAIL PROTECTED]>
+
+       * EventAPI += unloop.
+
 2000-04-24  Joshua Pritikin  <[EMAIL PROTECTED]>
 
        * Release 0.75.
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/Event.xs' 
'/usr/tmp/mp5304.d/new/Event-0.76/Event.xs'
Index: ./Event.xs
--- ./Event.xs  Tue Mar 21 09:07:23 2000
+++ ./Event.xs  Wed Apr 26 16:08:04 2000
@@ -306,6 +306,7 @@ BOOT:
       api->sv_2watcher = sv_2watcher;
       api->event_2sv = event_2sv;
       api->sv_2event = sv_2event;
+      api->unloop = pe_unloop;
       apisv = perl_get_sv("Event::API", 1);
       sv_setiv(apisv, (IV)api);
       SvREADONLY_on(apisv);
@@ -478,6 +479,7 @@ void
 _loop()
        CODE:
        pe_check_recovery();
+       pe_reentry();
        while (ExitLevel >= LoopLevel && ActiveWatchers) {
          ENTER;
          SAVETMPS;
@@ -485,6 +487,7 @@ _loop()
          FREETMPS;
          LEAVE;
        }
+       LEAVE; /* reentry */
 
 void
 _queue_pending()
@@ -496,7 +499,9 @@ _empty_queue(prio)
        int prio
        CODE:
        pe_check_recovery();
+       pe_reentry();
        while (pe_empty_queue(prio));
+       LEAVE; /* reentry */
 
 void
 queue_time(prio)
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/c/ev.c' 
'/usr/tmp/mp5304.d/new/Event-0.76/c/ev.c'
Index: ./c/ev.c
--- ./c/ev.c    Fri Mar 24 10:35:53 2000
+++ ./c/ev.c    Wed Apr 26 12:36:59 2000
@@ -222,20 +222,6 @@ static void pe_event_invoke(pe_event *ev
 
     /* SETUP */
     ENTER;
-    if (CurCBFrame >= 0) {
-       pe_watcher *pwa;
-       frp = CBFrame + CurCBFrame;
-       pwa = frp->ev->up;
-       assert(pwa->running == frp->run_id);
-       if (Estat.on)
-           Estat.suspend(frp->stats);
-       if (!WaREENTRANT(pwa) && WaREPEAT(pwa) && !WaSUSPEND(pwa)) {
-           /* temporarily suspend non-reentrant watcher until callback is
-              finished! */
-           pe_watcher_suspend(pwa);
-           SAVEDESTRUCTOR(_resume_watcher, pwa);
-       }
-    }
     SAVEINT(wa->running);
     PE_RING_DETACH(&ev->peer);
     frp = &CBFrame[++CurCBFrame];
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/c/queue.c' 
'/usr/tmp/mp5304.d/new/Event-0.76/c/queue.c'
Index: ./c/queue.c
--- ./c/queue.c Fri Mar  3 13:27:14 2000
+++ ./c/queue.c Wed Apr 26 16:16:31 2000
@@ -199,9 +199,42 @@ static int one_event(double tm) {  /**IN
     }
 }
 
+static void pe_reentry() {
+    pe_watcher *wa;
+    struct pe_cbframe *frp;
+
+    ENTER;  /* for SAVE*() macro (see below) */
+
+    if (CurCBFrame < 0)
+       return;
+
+    frp = CBFrame + CurCBFrame;
+    wa = frp->ev->up;
+    assert(wa->running == frp->run_id);
+    if (Estat.on)
+       Estat.suspend(frp->stats);  /* reversed by pe_event_postCB? */
+    if (WaREPEAT(wa)) {
+       if (WaREENTRANT(wa)) {
+           if (WaACTIVE(wa) && WaINVOKE1(wa))
+               pe_watcher_on(wa, 1);
+       } else {
+           if (!WaSUSPEND(wa)) {
+               /* temporarily suspend non-reentrant watcher until
+                  callback is finished! */
+               pe_watcher_suspend(wa);
+               SAVEDESTRUCTOR(_resume_watcher, wa);
+           }
+       }
+    }
+}
+
 static int safe_one_event(double maxtm) {
+    int got;
     pe_check_recovery();
-    return one_event(maxtm);
+    pe_reentry();
+    got = one_event(maxtm);
+    LEAVE; /* reentry */
+    return got;
 }
 
 static void pe_unloop(SV *why) {
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/lib/Event.pm' 
'/usr/tmp/mp5304.d/new/Event-0.76/lib/Event.pm'
Index: ./lib/Event.pm
--- ./lib/Event.pm      Mon Apr 24 09:43:21 2000
+++ ./lib/Event.pm      Wed Apr 26 13:13:50 2000
@@ -13,7 +13,7 @@ use Carp;
 eval { require Carp::Heavy; };  # work around perl_call_pv bug XXX
 use vars qw($VERSION @EXPORT_OK
            $API $DebugLevel $Eval $DIED $Now);
-$VERSION = '0.75';
+$VERSION = '0.76';
 
 # If we inherit DynaLoader then we inherit AutoLoader; Bletch!
 require DynaLoader;
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/lib/Event/EventAPI.h' 
'/usr/tmp/mp5304.d/new/Event-0.76/lib/Event/EventAPI.h'
Index: ./lib/Event/EventAPI.h
--- ./lib/Event/EventAPI.h      Mon Feb  7 13:28:45 2000
+++ ./lib/Event/EventAPI.h      Tue Apr 25 13:37:56 2000
@@ -208,6 +208,9 @@ struct EventAPI {
     void *(*sv_2watcher)(SV *sv);
     SV   *(*event_2sv)(pe_event *ev);
     void *(*sv_2event)(SV *sv);
+
+    /* EVERYTHING ELSE */
+    void (*unloop)(SV *);
 };
 
 static struct EventAPI *GEventAPI=0;
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/lib/Event/MakeMaker.pm' 
'/usr/tmp/mp5304.d/new/Event-0.76/lib/Event/MakeMaker.pm'
Index: ./lib/Event/MakeMaker.pm
--- ./lib/Event/MakeMaker.pm    Wed Dec 22 17:00:07 1999
+++ ./lib/Event/MakeMaker.pm    Tue Apr 25 13:29:59 2000
@@ -35,16 +35,16 @@ This is an advanced feature of Event.
 
 =head1 DESCRIPTION
 
-If you need optimal performance, you can hook into Event at the
-C-level.  You'll need to make changes to your C<Makefile.PL> and add
-code to your C<xs> or C<c> file(s).
+For optimal performance, hook into Event at the C-level.  You'll need
+to make changes to your C<Makefile.PL> and add code to your C<xs> /
+C<c> file(s).
 
 =head1 WARNING
 
-When you hook in at the C-level, you get a I<huge> performance gain
-but you reduce the chances that your code will work unmodified with
-newer versions of perl or L<Event>.  This may or not be a problem.
-Just be aware of it and set your expectations accordingly.
+When you hook in at the C-level you get a I<huge> performance gain,
+but you also reduce the chances that your code will work unmodified
+with newer versions of C<perl> or C<Event>.  This may or may not be a
+problem.  Just be aware, and set your expectations accordingly.
 
 =head1 HOW TO
 
gdiff -up '/usr/tmp/mp5304.d/old/Event-0.75/t/timer.t' 
'/usr/tmp/mp5304.d/new/Event-0.76/t/timer.t'
Index: ./t/timer.t
--- ./t/timer.t Fri Feb  4 08:17:48 2000
+++ ./t/timer.t Wed Apr 26 12:43:28 2000
@@ -1,9 +1,11 @@
 # the time for -*-perl-*-
 
-use Test; plan tests => 6;
+use Test; plan tests => 7;
 use Event qw(loop unloop);
 
-# $Event::DebugLevel = 4;
+# $Event::DebugLevel = 3;
+
+#if (0) {
 
 my $count = 0;
 Event->timer(after => 0.5, interval => .1, nice => -1,
@@ -37,3 +39,18 @@ $long->cb(sub { ok 1 });
 $long->at(time);
 
 ok loop(), 'ok';
+
+$_->cancel for Event::all_watchers();
+
+#}
+
+my $depth=0;
+Event->timer(interval => .01, cb => sub {
+                if (++$depth < 2) {
+                    loop();
+                } else {
+                    Event::unloop_all('reentrant');
+                }
+            });
+
+ok loop(), 'reentrant';
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Wed Apr 26 16:17:29 2000
# Generated by        : makepatch 2.00 (2.0BETA)
# Recurse directories : Yes
# p 'ChangeLog' 25114 956769217 0100444
# p 'Event.xs' 18510 956779684 0100444
# p 'c/ev.c' 7797 956767019 0100444
# p 'c/queue.c' 5203 956780191 0100444
# p 'lib/Event.pm' 4074 956769230 0100444
# p 'lib/Event/EventAPI.h' 5571 956684276 0100444
# p 'lib/Event/MakeMaker.pm' 3284 956683799 0100444
# p 't/timer.t' 871 956767408 0100444
#### End of ApplyPatch data ####

#### End of Patch kit [created: Wed Apr 26 16:17:29 2000] ####
#### Checksum: 260 7964 12339 ####

Reply via email to