Skip to content

Commit

Permalink
no need to write twice
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 27, 2016
1 parent 0928de8 commit 1bfe20d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -231,12 +231,10 @@ sub _write {
my $chunk = $tx->server_write;
delete $c->{writing};
warn term_escape "-- Server >>> Client (@{[_url($tx)]})\n$chunk\n" if DEBUG;
my $stream = $self->ioloop->stream($id)->write($chunk);

# Finish or continue writing
my $next = $tx->is_finished ? '_finish' : $chunk eq '' ? undef : '_write';
return $self->ioloop->stream($id)->write($chunk) unless $next;
weaken $self;
$stream->write('' => sub { $self->$next($id) }) if $next;
$self->ioloop->stream($id)->write($chunk => sub { $self->$next($id) });
}

1;
Expand Down

0 comments on commit 1bfe20d

Please sign in to comment.