Skip to content
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

Merged

Conversation

kou
Copy link
Contributor

@kou kou commented May 2, 2014

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.

@repeatedly
Copy link
Collaborator

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.
@kou
Copy link
Contributor Author

kou commented May 2, 2014

OK. I'm not in a hurry.

@repeatedly repeatedly self-assigned this May 2, 2014
@@ -0,0 +1,27 @@
require File.expand_path('../spec_helper', __FILE__)

describe Coolio::TCPSocket, :env => :win do
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

https://github.com/tarcieri/cool.io/blob/cd0fadffdd57e4398b4296a90899b95c6f33900c/spec/spec_helper.rb#L17

I will change this name after merged this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

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.

Copy link
Contributor Author

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!!!
repeatedly added a commit that referenced this pull request May 7, 2014
…watchers

Fix a bug that #close for unconnected Socket doesn't detach all watchers
@repeatedly repeatedly merged commit 2b70792 into socketry:master May 7, 2014
@repeatedly
Copy link
Collaborator

Thanks! Good catch 👍

@kou kou deleted the fix-socket-close-does-not-detach-all-watchers branch May 7, 2014 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants