-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added fix for thread error #341
Closed
nikhil2611
wants to merge
1
commit into
WinRb:master
from
nikhil2611:nikhil/CHEF-6359-memory-thread-error
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,12 +34,16 @@ def finalize(connection_opts, transport, shell_id) | |
end | ||
|
||
def close_shell(connection_opts, transport, shell_id) | ||
return false unless Thread.current.alive? | ||
Thread.current.wakeup if Thread.current.status =~ /sleep/ | ||
msg = WinRM::WSMV::CloseShell.new( | ||
connection_opts, | ||
shell_id: shell_id, | ||
shell_uri: WinRM::WSMV::Header::RESOURCE_URI_POWERSHELL | ||
) | ||
transport.send_request(msg.build) | ||
rescue ThreadError => e | ||
logger.debug("#{e.message}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern is that this just masks an error that should probably be raised. The underlying transport is still unable to close the shell which could result in orphaned powershell processes on the remote. |
||
end | ||
end | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, if
Thread.current
is not alive, how could this code be executing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thread is generally in asleep in my testing results. If it’s dead, I don’t think there’s much recourse that won’t potentially cause additional side effects. Maybe we rescue instead of returning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It strikes me as super odd that the thread would be sleeping if the code is actually running. In your testing, are you examining the thread status of
Thread.current
or are you observing the thread's status from a different thread.