Some AnyEvent::Handle methods keep a reference to $self preventing destruction

Mohammad Toossi mohammad at toossi.info
Wed Jul 20 07:33:55 CEST 2011


Sending to the official address.  This is a bug report regarding
AnyEvent version 5.34 (latest).

On Tue, Jul 19, 2011 at 10:18 PM, Mohammad Toossi <mohammad at toossi.info> wrote:
>
> I originally filed this on rt.cpan.org but got an auto-reply indicating that I should email the "official address" instead.  I cannot find the official address.  I hope one of these addresses is the right one.
> In AnyEvent::Handle, in register_read_type(storable => ...), the
> callback keeps a reference to $self. This means that in the following
> example, the Handle would not get destroyed despite setting it to undef:
>
> my $hdl = AnyEvent::Handle->new(fh => $child_fh);
> $hdl->push_read(storable => sub { print "got it\n"; });
> $hdl = undef;
>
> Here is a patch that fixes this. The same issue also happens for a
> couple of other read types but I don't really care about those!
>
> --- Handle.pm 2011-05-12 02:35:24.000000000 -0700
> +++ /usr/local/lib/perl/5.10.1/AnyEvent/Handle.pm 2011-07-19
> 20:28:54.405084002 -0700
> @@ -1735,7 +1735,7 @@
> if (my $ref = eval { Storable::thaw ($_[1]) }) {
> $cb->($_[0], $ref);
> } else {
> - $self->_error (Errno::EBADMSG);
> + $_[0]->_error (Errno::EBADMSG);
> }
> });
> }



More information about the anyevent mailing list