Skip to content

Commit

Permalink
trade a little performance for reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 27, 2016
1 parent 4ea4b70 commit 455e66e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -4,6 +4,7 @@
- Added closed method to Mojo::Transaction.
- Added parse_message method to Mojo::Transaction::WebSocket.
- Improved a few examples to avoid timing attacks.
- Fixed timing bug in Mojo::Server::Daemon.

6.42 2016-01-24
- Fixed use of deprecated Perl feature in Mojo::JSON.
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -135,6 +135,7 @@ sub _finish {
$c->{tx} = $ws->established(1);
weaken $self;
$ws->on(resume => sub { $self->_write($id) });
$self->_write($id);
}

# Failed upgrade
Expand Down Expand Up @@ -233,9 +234,7 @@ sub _write {
my $stream = $self->ioloop->stream($id)->write($chunk);

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

0 comments on commit 455e66e

Please sign in to comment.