Skip to content

Commit

Permalink
Branch on_readable for if windows or not
Browse files Browse the repository at this point in the history
  • Loading branch information
naritta committed Nov 30, 2015
1 parent 68b203b commit 1df7c96
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions lib/cool.io/listener.rb
Expand Up @@ -40,19 +40,28 @@ def on_connection(socket); end
#########

# Coolio callback for handling new connections
def on_readable
begin
on_connection @listen_socket.accept_nonblock
rescue Errno::EAGAIN, Errno::ECONNABORTED
# EAGAIN can be triggered here if the socket is shared between
# multiple processes and a thundering herd is woken up to accept
# one connection, only one process will get the connection and
# the others will be awoken.
# ECONNABORTED is documented in accept() manpages but modern TCP
# stacks with syncookies and/or accept()-filtering for DoS
# protection do not see it. In any case this error is harmless
# and we should instead spend our time with clients that follow
# through on connection attempts.
unless RUBY_PLATFORM =~ /mingw|mswin/
def on_readable
begin
on_connection @listen_socket.accept_nonblock
rescue Errno::EAGAIN, Errno::ECONNABORTED
# EAGAIN can be triggered here if the socket is shared between
# multiple processes and a thundering herd is woken up to accept
# one connection, only one process will get the connection and
# the others will be awoken.
# ECONNABORTED is documented in accept() manpages but modern TCP
# stacks with syncookies and/or accept()-filtering for DoS
# protection do not see it. In any case this error is harmless
# and we should instead spend our time with clients that follow
# through on connection attempts.
end
end
else
def on_readable
begin
on_connection @listen_socket.accept
rescue Errno::EAGAIN, Errno::ECONNABORTED
end
end
end
end
Expand Down

0 comments on commit 1df7c96

Please sign in to comment.