Fwd: CPAN Upload: JPRIT/Event-0.67.tar.gz

[email protected] (Joshua N Pritikin)
Newsgroups perl.loop
Message-ID <[email protected]>
----- Forwarded message from [email protected] -----

Date: Wed, 9 Feb 2000 22:17:53 +0100
Subject: CPAN Upload: JPRIT/Event-0.67.tar.gz
From: [email protected]
To: [email protected],
    [email protected]

The uploaded file

    Event-0.67.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/JPRIT/Event-0.67.tar.gz
  size: 65569 bytes
   md5: 4bbe8f32c35993d6dee6bfff5887dbc1

No action is required on your part
Request entered by: JPRIT (Joshua N. Pritikin)
Request entered on: Wed, 09 Feb 2000 21:16:27 GMT
Request completed:  Wed, 09 Feb 2000 21:17:53 GMT

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


----- End forwarded message -----

# This is a patch for Event-0.66 to update it to Event-0.67
# 
# 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.
# If you have a decent Bourne-type shell:
# STEP 2: Run the shell with this file as input.
# If you don't have such a shell, you may need to manually create
# the files as shown below.
# STEP 3: Run the 'patch' program with this file as input.
#
# These are the commands needed to create/delete files/directories:
#
touch 't/group.t'
chmod 0444 't/group.t'
#
# This command terminates the shell and need not be executed manually.
exit
#
#### End of Preamble ####

#### Patch data follows ####
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/ChangeLog' '/usr/tmp/mp18459.d/new/Event-0.67/ChangeLog'
Index: ./ChangeLog
--- ./ChangeLog	Tue Feb  8 16:53:18 2000
+++ ./ChangeLog	Wed Feb  9 16:10:47 2000
@@ -1,3 +1,15 @@
+2000-02-09  Joshua Pritikin  <[email protected]>
+
+	* Release 0.67.  Hopefully this release will prove stable.
+
+	* Fix bomb in group watchers. ([email protected])
+
+	* Fixed another bug introduced in 0.61.  (Insure++)
+
+	* Tighten typemap.
+
+	* Warn about non-existant methods.
+
 2000-02-08  Joshua Pritikin  <[email protected]>
 
 	* Release 0.66.
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/MANIFEST' '/usr/tmp/mp18459.d/new/Event-0.67/MANIFEST'
Index: ./MANIFEST
--- ./MANIFEST	Mon Feb  7 16:21:03 2000
+++ ./MANIFEST	Wed Feb  9 08:51:53 2000
@@ -51,6 +51,7 @@ t/callback.t
 t/delete.t
 t/eval.t
 t/fifo.t
+t/group.t
 t/hook.t
 t/hup.t
 t/idle.t
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/ev.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/ev.c'
Index: ./c/ev.c
--- ./c/ev.c	Tue Feb  8 15:46:37 2000
+++ ./c/ev.c	Tue Feb  8 17:21:26 2000
@@ -148,13 +148,8 @@ static void pe_event_postCB(pe_cbframe *
     pe_event *ev = fp->ev;
     pe_watcher *wa = ev->up;
     --CurCBFrame;
-    if (WaACTIVE(wa) && WaINVOKE1(wa) && WaREPEAT(wa)) {
-	char *excuse = pe_watcher_on(wa, 1);
-	if (SvIV(DebugLevel) && excuse) {
-	    STRLEN n_a;
-	    warn("Event: can't restart '%s' %s", SvPV(wa->desc,n_a), excuse);
-	}
-    }
+    if (WaACTIVE(wa) && WaINVOKE1(wa) && WaREPEAT(wa))
+	pe_watcher_on(wa, 1);
     if (Estat.on) {
 	if (fp->stats) {
 	    Estat.scrub(fp->stats, wa);
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/group.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/group.c'
Index: ./c/group.c
--- ./c/group.c	Mon Feb  7 16:17:11 2000
+++ ./c/group.c	Wed Feb  9 12:29:57 2000
@@ -95,6 +95,7 @@ static void pe_group_add(pe_group *gp, p
     if (!ok) {  /* expand array */
 	pe_watcher **ary;
 	EvNew(13, ary, gp->members*2, pe_watcher*);
+	Zero(ary, gp->members*2, pe_watcher*);
 	Copy(gp->member, ary, gp->members, sizeof(pe_watcher*));
 	EvFree(13, gp->member);
 	gp->member = ary;
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/io.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/io.c'
Index: ./c/io.c
--- ./c/io.c	Tue Feb  8 16:51:21 2000
+++ ./c/io.c	Tue Feb  8 17:20:49 2000
@@ -112,15 +112,9 @@ static void pe_io_alarm(pe_watcher *_wa,
 }
 
 static void _io_restart(pe_watcher *ev) {
-    char *excuse;
     if (!WaPOLLING(ev)) return;
     pe_watcher_off(ev);
-    excuse = pe_watcher_on(ev, 0);
-    if (SvIV(DebugLevel) && excuse) {
-	STRLEN n_a;
-	warn("Event: can't restart '%s' %s",
-	     SvPV(ev->desc, n_a), excuse);
-    }
+    pe_watcher_on(ev, 0);
 }
 
 static void pe_io_reset_handle(pe_watcher *ev) {  /* used by unix_io */
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/signal.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/signal.c'
Index: ./c/signal.c
--- ./c/signal.c	Tue Feb  8 15:47:49 2000
+++ ./c/signal.c	Tue Feb  8 17:24:47 2000
@@ -83,17 +83,9 @@ WKEYMETH(_signal_signal) {
 	    croak("Unrecognized signal '%s'", SvPV(nval, n_a));
 	if (!PE_SIGVALID(sig))
 	    croak("Signal '%s' cannot be caught", SvPV(nval, n_a));
-	/* factor XXX */
 	if (active) pe_watcher_off(ev);
 	sg->signal = sig;
-	if (active) {
-	    char *excuse = pe_watcher_on(ev, 0);
-	    if (SvIV(DebugLevel) && excuse) {
-		STRLEN n_a;
-		warn("Event: can't restart '%s' %s",
-		     SvPV(ev->desc, n_a), excuse);
-	    }
-	}
+	if (active) pe_watcher_on(ev, 0);
     }
 }
 
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/timer.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/timer.c'
Index: ./c/timer.c
--- ./c/timer.c	Tue Feb  8 15:46:55 2000
+++ ./c/timer.c	Tue Feb  8 17:22:15 2000
@@ -57,18 +57,10 @@ WKEYMETH(_timer_at) {
 	XPUSHs(sv_2mortal(newSVnv(tp->tm.at)));
 	PUTBACK;
     } else {
-	/* factor XXX */
 	int active = WaPOLLING(ev);
 	if (active) pe_watcher_off(ev);
 	tp->tm.at = SvNV(nval);
-	if (active) {
-	    char *excuse = pe_watcher_on(ev, 0);
-	    if (SvIV(DebugLevel) && excuse) {
-		STRLEN n_a;
-		warn("Event: can't restart '%s' %s",
-		     SvPV(ev->desc,n_a), excuse);
-	    }
-	}
+	if (active) pe_watcher_on(ev, 0);
     }
 }
 
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/typemap.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/typemap.c'
Index: ./c/typemap.c
--- ./c/typemap.c	Mon Feb  7 13:25:24 2000
+++ ./c/typemap.c	Wed Feb  9 08:47:22 2000
@@ -1,3 +1,5 @@
+#define MG_PRIVATE_CODE ((((unsigned)'e')<<8) + (unsigned)'v')
+
 static SV *wrap_watcher(void *ptr, HV *stash, SV *temple) {
     SV *ref;
     MAGIC **mgp;
@@ -26,6 +28,7 @@ static SV *wrap_watcher(void *ptr, HV *s
     Zero(mg, 1, MAGIC);
     mg->mg_type = '~';
     mg->mg_obj = (SV*) ptr;  /* NOT refcnt'd */
+    mg->mg_private = MG_PRIVATE_CODE;
     *mgp = mg;
 
     return ref;
@@ -50,8 +53,13 @@ static void* sv_2watcher(SV *sv) {
     if (!sv || !SvROK(sv))
 	croak("sv_2watcher: not a reference?");
     sv = SvRV(sv);
+    if (SvTYPE(sv) < SVt_PVMG)
+	croak("sv_2watcher: not a watcher");
     mg = mg_find(sv, '~');
     if (mg) {
+	if (mg->mg_private != MG_PRIVATE_CODE) {
+	    croak("Can't find event magic (SV=0x%x)", sv);
+	}
 	return (void*) mg->mg_obj;
     }
     croak("Attempt to use destroyed object (RV=0x%x %s=0x%x)",
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/var.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/var.c'
Index: ./c/var.c
--- ./c/var.c	Tue Feb  8 15:48:10 2000
+++ ./c/var.c	Tue Feb  8 17:24:51 2000
@@ -127,14 +127,9 @@ static void pe_var_stop(pe_watcher *_ev)
 }
 
 static void _var_restart(pe_watcher *ev) {
-    char *excuse;
     if (!WaPOLLING(ev)) return;
     pe_watcher_off(ev);
-    excuse = pe_watcher_on(ev, 0);
-    if (SvIV(DebugLevel) && excuse) {
-	STRLEN n_a;
-	warn("Event: can't restart '%s' %s", SvPV(ev->desc, n_a), excuse);
-    }
+    pe_watcher_on(ev, 0);
 }
 
 WKEYMETH(_var_events) {
@@ -162,17 +157,9 @@ WKEYMETH(_var_variable) {
 	    croak("Expecting a reference");
 	if (SvTYPE(SvRV(nval)) > SVt_PVMG)
 	    croak("Var watchers can only watch plain vanilla scalars");
-	/* factor XXX */
 	if (active) pe_watcher_off(ev);
 	vp->variable = SvREFCNT_inc(nval);
-	if (active) {
-	    char *excuse = pe_watcher_on(ev, 0);
-	    if (SvIV(DebugLevel) && excuse) {
-		STRLEN n_a;
-		warn("Event: can't restart '%s' %s",
-		     SvPV(ev->desc,n_a), excuse);
-	    }
-	}
+	if (active) pe_watcher_on(ev, 0);
 	SvREFCNT_dec(old);
     }
 }
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/c/watcher.c' '/usr/tmp/mp18459.d/new/Event-0.67/c/watcher.c'
Index: ./c/watcher.c
--- ./c/watcher.c	Tue Feb  8 16:46:59 2000
+++ ./c/watcher.c	Wed Feb  9 09:00:33 2000
@@ -105,8 +105,31 @@ WKEYMETH(_watcher_callback) {
 	    ev->callback = SvREFCNT_inc(nval);
 	} else if (SvROK(nval) &&
 		   (SvTYPE(av=(AV*)SvRV(nval)) == SVt_PVAV) &&
-		   av_len(av) == 1 &&
-		   !SvROK(sv=*av_fetch(av, 1, 0))) {
+		   av_len(av) == 1) {
+	    /* method lookup code adapted from universal.c */
+	    STRLEN n_a;
+	    SV *pkgsv = *av_fetch(av, 0, 0);
+	    HV *pkg = NULL;
+	    SV *namesv = *av_fetch(av, 1, 0);
+	    char *name = SvPV(namesv, n_a);
+	    int ok=0;
+	    if(SvROK(pkgsv)) {
+		pkgsv = (SV*)SvRV(pkgsv);
+		if(SvOBJECT(pkgsv))
+		    pkg = SvSTASH(pkgsv);
+	    }
+	    else {
+		pkg = gv_stashsv(pkgsv, FALSE);
+	    }
+	    if (pkg) {
+		GV *gv = gv_fetchmethod_autoload(pkg, name, FALSE);
+		if (gv && isGV(gv))
+		    ok=1;
+	    }
+	    if (!ok) {
+		warn("Event: callback method %s->%s doesn't exist",
+		     HvNAME(pkg), name);
+	    }
 	    WaPERLCB_on(ev);
 	    ev->callback = SvREFCNT_inc(nval);
 	} else {
@@ -310,25 +333,24 @@ static void pe_watcher_resume(pe_watcher
     if (WaDEBUGx(ev) >= 4)
 	warn("Event: resume '%s'%s%s\n", SvPV(ev->desc,n_a),
 	     WaACTIVE(ev)?" ACTIVE":"");
-    if (WaACTIVE(ev)) {
-	char *excuse = pe_watcher_on(ev, 0);
-	if (excuse)
-	    warn("Event: can't resume '%s' %s", SvPV(ev->desc,n_a), excuse);
-    }
+    if (WaACTIVE(ev))
+        pe_watcher_on(ev, 0);
 }
 
 static char *pe_watcher_on(pe_watcher *wa, int repeat) {
+    STRLEN n_a;
     char *excuse;
-    if (WaPOLLING(wa) || WaSUSPEND(wa)) return;
-    if (WaCANCELLED(wa)) {
-	STRLEN n_a;
+    if (WaPOLLING(wa) || WaSUSPEND(wa))
+	return 0;
+    if (WaCANCELLED(wa))
 	croak("Event: attempt to start cancelled watcher '%s'",
 	      SvPV(wa->desc,n_a));
-    }
     excuse = (*wa->vtbl->start)(wa, repeat);
-    if (excuse)
+    if (excuse) {
+	if (SvIV(DebugLevel))
+	    warn("Event: can't restart '%s' %s", SvPV(wa->desc, n_a), excuse);
 	pe_watcher_stop(wa, 1); /* update flags! */
-    else
+    } else
 	WaPOLLING_on(wa); /* must happen nowhere else!! */
     return excuse;
 }
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/lib/Event.pm' '/usr/tmp/mp18459.d/new/Event-0.67/lib/Event.pm'
Index: ./lib/Event.pm
--- ./lib/Event.pm	Tue Feb  8 16:53:36 2000
+++ ./lib/Event.pm	Wed Feb  9 16:11:04 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.66';
+$VERSION = '0.67';
 
 # If we inherit DynaLoader then we inherit AutoLoader; Bletch!
 require DynaLoader;
gdiff -up '/usr/tmp/mp18459.d/old/Event-0.66/t/callback.t' '/usr/tmp/mp18459.d/new/Event-0.67/t/callback.t'
Index: ./t/callback.t
--- ./t/callback.t	Fri Feb  4 08:14:56 2000
+++ ./t/callback.t	Tue Feb  8 17:46:38 2000
@@ -2,7 +2,7 @@
 
 use strict;
 use Test; plan tests => 3;
-use Event 0.53;
+use Event 0.65;
 
 my $invoked_method=0;
 sub method {
@@ -13,10 +13,14 @@ my $main = bless [];
 Event->timer(after => 0, cb => \&method);
 Event->timer(after => 0, cb => ['main', 'method']);
 Event->timer(after => 0, cb => [$main, 'method']);
+{
+    local $SIG{__WARN__} = sub {
+	ok $_[0], '/nomethod/';
+    };
+    Event->timer(after => 0, cb => [$main, 'nomethod'])->cancel;
+}
 
 eval { Event->timer(after => 0, cb => ['main']); };
-ok $@, '/Callback/';
-eval { Event->timer(after => 0, cb => ['main', \&method]); };
 ok $@, '/Callback/';
 
 Event::loop();
gdiff -up /dev/null '/usr/tmp/mp18459.d/new/Event-0.67/t/group.t'
Index: ./t/group.t
--- ./t/group.t	Wed Dec 31 19:00:00 1969
+++ ./t/group.t	Wed Feb  9 12:25:20 2000
@@ -0,0 +1,23 @@
+#!./perl -w
+
+use Test; plan test => 3;
+use Event;
+require Event::group;
+
+my $gp = Event->group(timeout => 5, cb => \&die);
+
+my $undef;
+eval { $gp->add(\$undef) };
+ok $@, '/not a watcher/';
+
+eval { $gp->add(\$gp) };
+ok $@, '/not a watcher/';
+
+eval { $gp->add($gp) };
+ok $@, '/itself/';
+
+for (1..10) {
+    $gp->add(Event->timer(after => 5, cb => \&die));
+}
+
+# need more tests here! XXX
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Wed Feb  9 16:22:14 2000
# Generated by        : makepatch 2.00 (2.0BETA)
# Recurse directories : Yes
# p 'ChangeLog' 22355 950130647 0100444
# p 'MANIFEST' 896 950104313 0100444
# p 'c/ev.c' 8006 950048486 0100444
# p 'c/group.c' 3669 950117397 0100444
# p 'c/io.c' 5527 950048449 0100444
# p 'c/signal.c' 4024 950048687 0100444
# p 'c/timer.c' 2351 950048535 0100444
# p 'c/typemap.c' 3893 950104042 0100444
# p 'c/var.c' 4570 950048691 0100444
# p 'c/watcher.c' 9085 950104833 0100444
# p 'lib/Event.pm' 4254 950130664 0100444
# p 't/callback.t' 492 950049998 0100444
# c 't/group.t' 0 950117120 0100444
#### End of ApplyPatch data ####

#### End of Patch kit [created: Wed Feb  9 16:22:14 2000] ####
#### Checksum: 401 12483 64817 ####

-- 
"Never ascribe to malice that which can be explained by stupidity."
                            via, but not speaking for Deutsche Bank
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.