Subject: | UNLOAD bug. |
Irssi doesnt clean up properly if you load a script twice (or more)
without unloading explicitly.
I think Irssi isnt explicitly freeing the $postbacks that Irssi.pm is
giving it with signal_add() until the script is explicitly unloaded.
This explains why the three sessions suddenly _stop.
I am working on a patch to fix this (maybe). Depends on if
Irssi::signal_remove() will work with postbacks.
Subject: | utest.pl |
use strict;
use Glib;
use POE qw/Loop::Glib/;
use POE::Session::Irssi;
POE::Session::Irssi->create(
irssi_signals => {
"beep" => sub { print "BEEP"; },
},
inline_states => {
_start => sub {
print "_start";
$_[KERNEL]->sig('unload','_shutdown');
$_[KERNEL]->refcount_increment( $_[SESSION], 'imitate a external thingy' );
},
_shutdown => sub {
print "Got signal";
$_[KERNEL]->call( $_[SESSION], 'shutdown' ) if $_[ARG1] eq __PACKAGE__;
},
shutdown => sub {
print "Shutting down";
$_[KERNEL]->refcount_decrement( $_[SESSION], 'imitate a external thingy' );
},
_stop => sub {
print "_stop";
},
},
);
__END__
[16:53:03] -!- /LOAD test
[16:53:08] _start
[16:53:11] -!- /UNLOAD test
[16:53:14] -!- Irssi: Unloaded script utest
[16:53:14] UNLOAD Irssi::Script::utest
[16:53:14] Got signal
[16:53:14] Shutting down
[16:53:14] _stop
[16:53:25] -!- /LOAD test
[16:53:27] _start
[16:53:29] -!- /LOAD test
[16:53:31] UNLOAD Irssi::Script::utest
[16:53:31] _start
[16:53:31] Got signal
[16:53:31] Shutting down
[16:53:31] Got signal
[16:53:31] Shutting down
[16:53:32] -!- /LOAD test
[16:53:34] UNLOAD Irssi::Script::utest
[16:53:34] _start
[16:53:34] Got signal
[16:53:34] Shutting down
[16:53:34] Got signal
[16:53:34] Shutting down
[16:53:34] Got signal
[16:53:34] Shutting down
[16:53:39] -!- /UNLOAD test
[16:53:43] -!- Irssi: Unloaded script utest
[16:53:43] UNLOAD Irssi::Script::utest
[16:53:43] Got signal
[16:53:43] Shutting down
[16:53:43] Got signal
[16:53:43] Shutting down
[16:53:43] Got signal
[16:53:43] Shutting down
[16:53:43] _stop
[16:53:43] _stop
[16:53:43] _stop