[poe-commits] poe/lib/POE/Loop Event.pm,1.38,1.39
Brought to you by:
rcaputo
From: <rc...@us...> - 2004-08-03 20:08:45
|
Update of /cvsroot/poe/poe/lib/POE/Loop In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv373/lib/POE/Loop Modified Files: Event.pm Log Message: Ton Hospel discovered that POE::Loop::Event does not exit when an event handler calls C<die>. The problem turned out to be Event.pm's default exception handler, which turns the C<die> into a harmless C<warn> and resumes the event loop. Well, POE's all inconsistent inside and nothing will happen, so the program stalls hard. Even Ctrl+C and Ctrl+\ don't terminate it. This commit replaces the default excetion handler, turning it into a harmless C<warn> followed by an equally harmless (yet eminently terminal) C<exit>. I originally tried to use C<die> inside the exception handler, even setting $SIG{__DIE__} = "DEFAULT", but it only sufficed to change the original warning into some twisted, recursive form of it. And of course the program didn't actually die. Now at least it exits. Index: Event.pm =================================================================== RCS file: /cvsroot/poe/poe/lib/POE/Loop/Event.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Event.pm 21 May 2004 22:37:45 -0000 1.38 --- Event.pm 3 Aug 2004 20:08:36 -0000 1.39 *************** *** 23,29 **** --- 23,37 ---- # Loop construction and destruction. + sub _our_event_exception_handler { + my ($event, $message) = @_; + warn $message; + exit 1; + } + sub loop_initialize { my $self = shift; + $Event::DIED = \&_our_event_exception_handler; + $_watcher_timer = Event->timer( cb => \&_loop_event_callback, |