Skip to content

Commit

Permalink
Fix channels after a closed shell
Browse files Browse the repository at this point in the history
Channel#close gets called lots of times, so make sure that closing the
lsock doesn't break things by rescuing IOError.
  • Loading branch information
egypt committed Jan 8, 2012
1 parent 1943638 commit 3411f11
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions meta_ssh/lib/rex/post/meta_ssh/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ def close
self.client.remove_channel(self)
self.monitor.kill if self.monitor
self.thread.kill if self.thread
self.channel.close
self.lsock.close
rescue Exception => e
puts e
self.channel.close if self.channel
self.lsock.close if self.lsock
monitor = thread = channel = lsock = nil
rescue ::IOError
# This happens if we get called in another thread before the lsock gets
# set to nil. Doesn't cause any trouble since the channel is closing
# anyway, so just ignore.
rescue ::Exception => e
# Something went wrong but the channel is dead anyway, so just log it and
# ignore.
elog "Exception while cleaning up channel: #{e.class}: #{e}"
end
end

Expand Down

0 comments on commit 3411f11

Please sign in to comment.