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

Add Socket Manager API and Windows support #28

Merged
merged 2 commits into from
Dec 9, 2015

Conversation

naritta
Copy link
Contributor

@naritta naritta commented Nov 30, 2015

This is continued from below.
#25 Sharing sockets between multiprocess workers with Socket Manager
#26 Windows support for signal handling and dealing with IO

@@ -204,14 +219,31 @@ def tick(blocking_timeout=0)
return nil
end

ready_pipes, _, _ = IO.select(@rpipes.keys, nil, nil, blocking_timeout)
if ServerEngine.windows?
@rpipes.each{|r, m|
Copy link
Member

Choose a reason for hiding this comment

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

why is this section necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because Win32::Pipe::Server doesn't cause EOFError even when a child process exits.
(https://github.com/fluent/serverengine/pull/26/files#diff-1e5e735f236537f81cca69fb746da179R221)

Then I think we should adapt to child process exits by Process.waitpid2 and if child process exits, we have to close pipe.

I think we can use WaitForMultipleObjects, but function is almost same and Process.waitpid2 is easier to use. Then I used that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, win32-pipe is not stable and hard to use, because there are many bugs.
Then I think we should use UDPSocket for Heartbeat if it is allowed.

Copy link
Member

Choose a reason for hiding this comment

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

if my understanding is correct, pipe won't be invalid even when a connecting process exists because another client can connect there. That's the reason why EOFError doesn't happen.

As I commented on #26 (comment), another idea is to not implement heartbeat at all on windows. I think it's good enough and make it simple. it mans that ProcessManager#tick does nothing excepting @monitors.delete_if {|m| !m.tick(time) } and sleep. Any thoughts there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got it. I think so, too.
I fixed it.

@frsyuki
Copy link
Member

frsyuki commented Dec 4, 2015

@naritta Very good. Can I ask you following items to merge this awesome work?

  • a) Could you add a simple test cases of SocketManager on Windows? (here: https://github.com/fluent/serverengine/pull/28/files#diff-96c336025ad565bd2282a761368b9dbcR22). You may assume that it will be an example usage of SocketManager on Windows.
  • b) CI (Travis CI and AppVeyor) is failing. Could you check it?
  • c) Could you squash changes into a simple commit or commits?
  • d) It seems that win32-pipe is not used any more. Could you update gemspec file?
  • e) If everything is ready to merge, please let me know.

@naritta naritta changed the title Socket Manager API Add Socket Manager API and Windows support Dec 6, 2015
@naritta
Copy link
Contributor Author

naritta commented Dec 6, 2015

@frsyuki
Thank you for the reviewing. I think it's ready to merge

I added AppVeyor support and I fixed previous problem in travis-ci.
b0a981d#diff-180360612c6b8c4ed830919bbb4dd459R2
a587639#diff-26195760b9c62e6865cd2a0136372463R25
There is other problem in Travis-ci, but I guess this is bugs in Travis-ci.

@frsyuki frsyuki merged commit a587639 into treasure-data:master Dec 9, 2015
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.

2 participants