Skip to content

Commit

Permalink
removed experimental status from max_accepts attribute in Mojo::IOLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 22, 2012
1 parent 8fe4011 commit 96c8010
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,8 @@ This file documents the revision history for Perl extension Mojolicious.

2.65 2012-03-22 00:00:00
- Added one_tick method to Mojo::Reactor and Mojo::Reactor::EV.
- Removed experimental status from max_accepts attribute in
Mojo::IOLoop.
- Updated jQuery to version 1.7.2.
- Improved documentation.
- Improved tests.
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -382,8 +382,7 @@ captured.
The maximum number of connections this loop is allowed to accept before
shutting down gracefully without interrupting existing connections, defaults
to C<0>. Setting the value to C<0> will allow this loop to accept new
connections indefinitely. Note that this attribute is EXPERIMENTAL and might
change without warning!
connections indefinitely.
=head2 C<max_connections>
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Reactor.pm
Expand Up @@ -167,7 +167,7 @@ L<Mojo::Reactor> is a minimalistic low level event reactor based on
L<IO::Poll> and the foundation of L<Mojo::IOLoop>. Note that this module is
EXPERIMENTAL and might change without warning!
# A new reactor backend could look like this
# A new reactor implementation could look like this
package Mojo::Reactor::MyLoop;
use Mojo::Base 'Mojo::Reactor';
Expand Down
26 changes: 16 additions & 10 deletions t/mojo/ioloop.t
Expand Up @@ -6,7 +6,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor';
}

use Test::More tests => 30;
use Test::More tests => 32;

# "Marge, you being a cop makes you the man!
# Which makes me the woman, and I have no interest in that,
Expand Down Expand Up @@ -188,8 +188,7 @@ $err = undef;
$loop->client(
(port => $port) => sub {
shift->stop;
pop;
$err = pop;
$err = shift;
}
);
$loop->start;
Expand Down Expand Up @@ -260,20 +259,27 @@ ok length($server) > length($server_after), 'stream has been resumed';
is $client, $client_after, 'stream was writable while paused';
is $client, 'works!', 'full message has been written';

# Graceful shutdown
# Graceful shutdown (max_connections)
$err = '';
$loop = Mojo::IOLoop->new(max_connections => 0);
$loop->drop($loop->client({port => $loop->generate_port}));
$loop->timer(
1 => sub {
shift->stop;
$err = 'failed!';
}
);
$loop->timer(1 => sub { shift->stop; $err = 'failed!' });
$loop->start;
ok !$err, 'no error';
is $loop->max_connections, 0, 'right value';

# Graceful shutdown (max_accepts)
$err = '';
$loop = Mojo::IOLoop->new(max_accepts => 1);
$port = $loop->generate_port;
$loop->server(
{address => '127.0.0.1', port => $port} => sub { shift; shift->close });
$loop->client({port => $port} => sub { });
$loop->timer(1 => sub { shift->stop; $err = 'failed!' });
$loop->start;
ok !$err, 'no error';
is $loop->max_accepts, 1, 'right value';

# Defaults
is(
Mojo::IOLoop::Client->new->reactor,
Expand Down

0 comments on commit 96c8010

Please sign in to comment.