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

Unable to stop timeout #6

Closed
und3f opened this issue Jan 12, 2017 · 1 comment
Closed

Unable to stop timeout #6

und3f opened this issue Jan 12, 2017 · 1 comment

Comments

@und3f
Copy link

und3f commented Jan 12, 2017

on_timeout keep executing even after Handle ->destroy

#! perl

use strict;
use warnings FATAL   => 'all';
use Test::More tests => 2;
use AnyEvent::Handle::UDP;
use Socket qw/unpack_sockaddr_in/;
use IO::Socket::INET;

alarm 6;

{

    my $addr = inet_aton('localhost');
    socket my $socket, PF_INET, SOCK_DGRAM, 0
      or die "Unable to create socket: $!";
    connect $socket, pack_sockaddr_in(0, $addr) or die "connect: $!";
    my $sockaddr = getsockname $socket;

    my $client;
    my $cb = sub {
        is shift, "TIMEOUT", 'first client timed out';
        $client->destroy;
    };

    $client = AnyEvent::Handle::UDP->new(
        connect    => $sockaddr,
        on_recv    => $cb,
        on_error   => $cb,
        timeout    => 1,
        on_timeout => sub { $cb->("TIMEOUT"); return; },
    );

    my $cb2    = AE::cv;
    my $client2 = AnyEvent::Handle::UDP->new(
        connect    => $sockaddr,
        on_recv    => $cb2,
        on_error   => $cb2,
        timeout    => 4,
        on_timeout => sub { $cb2->("TIMEOUT"); return; },
    );

    $client->push_send('test');
    $client2->push_send('test');

    is(
        $cb2->recv,
        "TIMEOUT",
        'second client timed out'
    );
}
@Leont
Copy link
Owner

Leont commented Jan 12, 2017

Fixed in 0.048

@Leont Leont closed this as completed Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants