From 5249c6b54b0ff5f463870ecd9c59cfdea04a6514 Mon Sep 17 00:00:00 2001 From: Tatsuhiko Miyagawa Date: Wed, 3 Feb 2010 23:51:21 -0800 Subject: [PATCH] Only store writer when there's no body. This revealed a rare condition where the handler returns something that is expected to be garbage collected, like EV::IO from AnyEvent::HTTPD's ->respond method and causes issues. --- lib/Tatsumaki/Handler.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Tatsumaki/Handler.pm b/lib/Tatsumaki/Handler.pm index 984794f..5061403 100644 --- a/lib/Tatsumaki/Handler.pm +++ b/lib/Tatsumaki/Handler.pm @@ -114,8 +114,9 @@ sub run { $cv->cb(sub { my $cv = shift; try { - my $w = $start_response->($cv->recv); - if ($w) { + my $res = $cv->recv; + my $w = $start_response->($res); + if (!$res->[2] && $w) { $self->writer($w); $self->condvar(my $cv2 = AE::cv); $self->request->env->{'psgix.block.body'} = sub { $cv2->recv };