Subject: | The shutdown method needs a new option to actually shutdown |
Hello,
I am using this module in many places and it's been a pleasure to use!
Today I encountered something that I never saw before, and immediately
thought "arg!" :)
The issue is that I'm wrapping a Net::SFTP::Foreign process which
basically controls a ssh connection via the external binary "ssh". If
ssh is misconfigured/etc it will attempt to ask a password on connect. (
yes, I can use Net::SFTP::Foreign's Expect support to supply the
password but I don't want it in the first place )
I have a timeout timer that will fire if the connection wasn't
successful after some time. When that is triggered, I call ->shutdown on
the object and undef it on my side. I was surprised to see the process
still hanging!
The issue is that ->shutdown does a "graceful" shutdown of the child
process. While this is desirable in many cases, what I need is a
"shutdown NOW" method :)
There is 2 ways to do this - add a new method, "shutdown_hard" or
something like that, or supply an argument to the shutdown method to
enable/disable hard shutdown. For now I've "worked" around that
limitation in my code by doing this:
# $self->sftp is the poco-generic object
$self->sftp->{'wheel'}->kill( 'KILL' );
$poe_kernel->call( $self->sftp->session_id, 'shutdown' );
$self->sftp( undef );
This would work and kill the subprocess cleanly! However, I am still
getting spurious events sent to my session after I do the shutdown. On
further investigation it's because the refcount for my session is still
"hanging" around and it somehow makes poco-generic send events to me
after the wheel is shutdown...
Thanks again for investigating this and hope we can find a solution!
--
~Apocalypse