Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
simplified Mojo::IOLoop::Stream cleanup logic
  • Loading branch information
kraih committed Dec 17, 2011
1 parent 5648823 commit 58bbb25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -30,7 +30,7 @@ sub is_readable {

sub is_writing {
my $self = shift;
return if $self->{closed};
return unless exists $self->{handle};
return length($self->{buffer}) || $self->has_subscribers('drain');
}

Expand Down Expand Up @@ -91,14 +91,11 @@ sub write {
sub _close {
my $self = shift;

# Already closed
return if $self->{closed}++;

# Cleanup
return unless my $handle = delete $self->{handle};
return unless my $watcher = $self->{iowatcher};
return unless my $handle = $self->{handle};
$watcher->drop_handle($handle);
$watcher->drop_timer($self->{timer}) if $self->{timer};
$watcher->drop_timer(delete $self->{timer}) if $self->{timer};

# Close
close $handle;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -460,7 +460,7 @@ and the application object, as well as a function in C<ep> templates.
$app->hook(after_dispatch => sub {...});
Extend L<Mojolicious> by adding hooks.
Extend L<Mojolicious> with hooks.
# Dispatchers will not run if there's already a response code defined
$app->hook(before_dispatch => sub {
Expand Down

0 comments on commit 58bbb25

Please sign in to comment.