Permalink
Browse files

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.
  • Loading branch information...
miyagawa committed Feb 4, 2010
1 parent 4b49c30 commit 5249c6b54b0ff5f463870ecd9c59cfdea04a6514
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/Tatsumaki/Handler.pm
View
@@ -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 };

0 comments on commit 5249c6b

Please sign in to comment.