Skip Menu |

This queue is for tickets about the Asterisk-AMI CPAN distribution.

Report information
The Basics
Id: 132967
Status: new
Priority: 0/
Queue: Asterisk-AMI

People
Owner: Nobody in particular
Requestors: ad_user [...] runbox.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: can't safe break() a loop on network error
Date: Thu, 9 Jul 2020 13:39:32 +1000
To: bug-Asterisk-AMI [...] rt.cpan.org
From: Alex 'AdUser' Z <ad_user [...] runbox.com>
The problem: after receiving network error on socket, Asterisk AMI calls internal _on_error routine, executes user's on_error() callback if defined and destroys object itself, ...but keeps underlying event-loop running. Calling a break() manually in on_error() callback gives segfault. The only way to break that loop now is call exit(), because internally used in loop()/break() AnyEvent condvar reference get lost. Possible fix is make copy of that reference and send() to it after Asterisk::AMI object gets destroyed. --- minimal code: sub on_error { my ($ami, $str) = @_; printf "* socket error: %s\n", $str; $ami->break; # <- segfault if uncommented, endless loop otherwise } my $ami = Asterisk::AMI->new( ... Blocking => 0, Keepalive => 10, on_error => \&on_error, ); $ami->loop; exit 0; # never reached --- output: <time passes> * socket error: Broken pipe double free or corruption (out) -- -- Alex