Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed small bug where Mojo::IOLoop::Stream timeout was not always ava…
…ilable
  • Loading branch information
kraih committed Aug 8, 2013
1 parent 0160565 commit 7f66812
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Changes
@@ -1,5 +1,7 @@

4.24 2013-08-06
4.24 2013-08-08
- Fixed small bug where Mojo::IOLoop::Stream timeout was not always
available.

4.23 2013-08-01
- Added redirects method to Mojo::Transaction::HTTP.
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -11,7 +11,7 @@ has reactor => sub {

sub DESTROY { shift->close }

sub new { shift->SUPER::new(handle => shift, buffer => '') }
sub new { shift->SUPER::new(handle => shift, buffer => '', timeout => 15) }

sub close {
my $self = shift;
Expand Down Expand Up @@ -47,8 +47,8 @@ sub start {
my $self = shift;

my $reactor = $self->reactor;
$reactor->io($self->timeout(15)->{handle},
sub { pop() ? $self->_write : $self->_read })
my $cb = sub { pop() ? $self->_write : $self->_read };
$reactor->io($self->timeout($self->{timeout})->{handle} => $cb)
unless $self->{timer};

# Resume
Expand Down
1 change: 1 addition & 0 deletions t/mojo/ioloop.t
Expand Up @@ -130,6 +130,7 @@ Mojo::IOLoop->client(
);
$handle = $delay->wait->steal_handle;
my $stream = Mojo::IOLoop::Stream->new($handle);
is $stream->timeout, 15, 'right default';
$id = Mojo::IOLoop->stream($stream);
$stream->on(close => sub { Mojo::IOLoop->stop });
$stream->on(read => sub { $buffer .= pop });
Expand Down

0 comments on commit 7f66812

Please sign in to comment.