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
Fix a bug that #close for unconnected Socket doesn't detach all watchers #33
Fix a bug that #close for unconnected Socket doesn't detach all watchers #33
Conversation
Thanks! I will check it later. |
`Coolio::IO#close` should detach all own watchers. But `#close` of `Coolio::Socket (< Coolio::IO)` doesn't detach all own watchers when the socket isn't connected yet. `Coolio::IO#close` detaches attached watchers. It uses `Coolio::IO#attached?` to detect an attached watcher. `Coolio::Socket` delegates some operations such as attach and detach to its internal connector before the socket is connected yet. But it doesn't delegate `#attached?`. So `Coolio::IO#close` can't detect an attached watcher by its internal connector. So an attached watcher isn't detached by `#close`. See the committed spec how to reproduce this problem.
OK. I'm not in a hurry. |
@@ -0,0 +1,27 @@ | |||
require File.expand_path('../spec_helper', __FILE__) | |||
|
|||
describe Coolio::TCPSocket, :env => :win do |
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.
:env => :win
is needed?
This test should pass on Windows because doesn't depend on Linux / Mac features like Unix Domain Socket.
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.
Ah, sorry. I misunderstood.
I thought that :env => :win
is for running the description on Windows too.
I didn't run the description on Windows but it will not be needed.
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.
Yeah. It is very confused name but currently :env => :win
is used to skip specs on Windows.
I will change this name after merged this PR.
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.
Thanks!
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.
Could you remove this?
Other code looks Okay so I can merge PR.
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.
OK. I've removed it.
`:env => :win` means that the example doesn't run on Windows. The example should work on Windows. So `:env => :win` should not be specified. Reported by Masahiro Nakagawa. Thanks!!!
…watchers Fix a bug that #close for unconnected Socket doesn't detach all watchers
Thanks! Good catch 👍 |
Coolio::IO#close
should detach all own watchers. But#close
ofCoolio::Socket (< Coolio::IO)
doesn't detach all own watchers whenthe socket isn't connected yet.
Coolio::IO#close
detaches attached watchers. It usesCoolio::IO#attached?
to detect an attached watcher.Coolio::Socket
delegates some operations such as attach and detachto its internal connector before the socket is connected yet. But it
doesn't delegate
#attached?
. SoCoolio::IO#close
can't detect anattached watcher by its internal connector. So an attached watcher
isn't detached by
#close
.See the committed spec how to reproduce this problem.