Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix bug in Mojo::IOLoop where stopping gracefully would sometimes res…
…ult in connections getting closed too early (closes #947)
  • Loading branch information
kraih committed Apr 25, 2016
1 parent fc01dad commit 80a4f3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Changes
@@ -1,5 +1,7 @@

6.60 2016-04-23
6.60 2016-04-25
- Fixed bug in Mojo::IOLoop where stopping gracefully would sometimes result
in connections getting closed too early. (anparker, sri)

6.59 2016-04-22
- Removed deprecated xss_escape function from Mojo::Util.
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -112,15 +112,15 @@ sub server {
$server->on(
accept => sub {

my $stream = Mojo::IOLoop::Stream->new(pop);
$self->$cb($stream, $self->_stream($stream, $self->_id, 1));

# Enforce connection limit (randomize to improve load balancing)
if (my $max = $self->max_accepts) {
$self->{accepts} //= $max - int rand $max / 2;
$self->stop_gracefully if ($self->{accepts} -= 1) <= 0;
}

my $stream = Mojo::IOLoop::Stream->new(pop);
$self->$cb($stream, $self->_stream($stream, $self->_id, 1));

# Stop accepting if connection limit has been reached
$self->_not_accepting if $self->_limit;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Mojolicious.pm
Expand Up @@ -783,6 +783,8 @@ Alexey Likhatskiy
Anatoly Sharifulin
Andre Parker
Andre Vieth
Andreas Jaekel
Expand Down

0 comments on commit 80a4f3f

Please sign in to comment.