Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOLoop doesn't close a connection on drop #173

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 31 additions & 1 deletion t/mojo/ioloop.t
Expand Up @@ -6,7 +6,7 @@ use warnings;
# Disable IPv6, epoll and kqueue
BEGIN { $ENV{MOJO_NO_IPV6} = $ENV{MOJO_POLL} = 1 }

use Test::More tests => 11;
use Test::More tests => 12;

use_ok 'Mojo::IOLoop';

Expand Down Expand Up @@ -123,4 +123,34 @@ Mojo::IOLoop->idle(sub { Mojo::IOLoop->stop if $idle++ });
Mojo::IOLoop->start;
is $idle, 2, 'two idle ticks';

$port = Mojo::IOLoop->generate_port;
$id = $loop->listen(port => $port);
$loop->connect(
address => 'localhost',
port => $port,
on_connect => sub {
my $loop = shift;
$loop->drop($id);
$loop->stop;
}
);

$loop->start;

my $not_connected;
$loop->connect(
address => 'localhost',
port => $port,
on_error => sub { shift->stop },
on_connect => sub {
my $loop = shift;
$not_connected = 0;
$loop->stop;
}
);

$loop->start;

ok $not_connected;

__DATA__