Hello,
I'm getting started with Twiggy and have already found a way to crash it.
My app is like this (in fact, slightly modified example from PSGI man
page regarding delayed response, see:
http://search.cpan.org/~miyagawa/PSGI-1.10/PSGI.pod#Delayed_Response_and_Streaming_Body
):
#!/usr/bin/perl -w
use strict;
use AnyEvent;
my $app = sub {
my $env = shift;
return sub {
my $responder = shift;
my $writer = $responder->([200, [ 'Content-Type' => 'text/plain' ]]);
# set up timer
my $tm;
my $stage;
$tm = AnyEvent->timer( after => 1, interval => 1, cb => sub {
if (++$stage<=5) {
# print 1..5
$writer->write($stage);
} else {
# stop here
$writer->close;
$tm = undef;
};
});
};
};
So we send 12345 to user in 5 seconds.
Now, I want to simulate the user falling off and so I ran
% perl -we 'alarm 1; use LWP::UserAgent; \
my $ag = LWP::UserAgent->new; $ag->get("http://127.1:5000/");'
And suddenly, on my Ubuntu Twiggy died with error message
AnyEvent::Handle uncaught error: Broken pipe at
/home/kuvarin/lib/perl/5.10.1/Twiggy/Server.pm line 601
On FreeBSD I got a warning message instead.
The error is 100% reproducible with Twiggy 0.1020 on both machines.
As I understand by reading AnyEvent::Handle's source, it can be avoided
by setting an on_error handler in handle's constructor.
I'd like to do more research here, and would appreciate any help. Thanks
for your time,
Konstantin S. Uvarin