Skip Menu |

This queue is for tickets about the POE-Session-Irssi CPAN distribution.

Report information
The Basics
Id: 28806
Status: rejected
Priority: 0/
Queue: POE-Session-Irssi

People
Owner: martijn [...] cpan.org
Requestors: immute [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 0.2
  • 0.3
Fixed in: (no value)



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
Subject: [rt.cpan.org #28806] AutoReply: UNLOAD bug.
Date: Sun, 12 Aug 2007 17:24:57 -0500
To: bug-POE-Session-Irssi [...] rt.cpan.org
From: Matt Sickler <crazyfordynamite [...] gmail.com>
I think the only way to avoid this issue is to some how wrap the subrefs we pass to signal_add() and command_bind() that will not keep POE alive, but will somehow make sure that the session is actually around before calling the sub. I don't think this is a good way because it will still leak memory over time. The only thing I can think of is calling Irssi::command("script unload <script name>"); in _shutdown (from my test case). It will prevent the reload from working, but at least it doesn't leak memory. I'm going to bug the irssi devs about this and see what they say.
I've tried running your test script, but it didn't run out of the box. After a bit of fiddling, I got it working, but it doesn't display the behaviour from the log. It loads and unloads just fine here There was a lot of unneccesary stuff in your test script, so I cut out all the unnecessary parts. Could you try with this one? I issued the following commands: /script load utest.pl /foo /script load utest.pl /foo /script unload utest.pl with the following output: 13:06 _start 13:06 -!- Irssi: Loaded script utest 13:06 BEEP 13:06 _stop 13:06 UNLOAD Irssi::Script::utest 13:06 _start 13:06 -!- Irssi: Loaded script utest 13:06 BEEP 13:06 -!- Irssi: Unloaded script utest 13:06 UNLOAD Irssi::Script::utest 13:06 _stop
use lib 'lib'; use strict; use Glib; use POE qw/Loop::Glib/; use POE::Session::Irssi; POE::Session::Irssi->create( irssi_commands => { "foo" => sub { print "BEEP"; }, }, inline_states => { _start => sub { print "_start"; }, _stop => sub { print "_stop"; }, }, );