summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/lib/socket.rb14
2 files changed, 9 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f9d08e..40005aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Nov 17 10:12:30 2015 Eric Wong <e@80x24.org>
+
+ * ext/socket/lib/socket.rb (Socket.accept_loop): avoid exceptions
+ (Socket.udp_server_recv): ditto
+
Tue Nov 17 09:59:00 2015 Eric Wong <e@80x24.org>
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid arg parsing
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index 705a0b8..c9929ae 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -792,11 +792,8 @@ class Socket < BasicSocket
loop {
readable, _, _ = IO.select(sockets)
readable.each {|r|
- begin
- sock, addr = r.accept_nonblock
- rescue IO::WaitReadable
- next
- end
+ sock, addr = r.accept_nonblock(exception: false)
+ next if sock == :wait_readable
yield sock, addr
}
}
@@ -960,11 +957,8 @@ class Socket < BasicSocket
#
def self.udp_server_recv(sockets)
sockets.each {|r|
- begin
- msg, sender_addrinfo, _, *controls = r.recvmsg_nonblock
- rescue IO::WaitReadable
- next
- end
+ msg, sender_addrinfo, _, *controls = r.recvmsg_nonblock(exception: false)
+ next if msg == :wait_readable
ai = r.local_address
if ai.ipv6? and pktinfo = controls.find {|c| c.cmsg_is?(:IPV6, :PKTINFO) }
ai = Addrinfo.udp(pktinfo.ipv6_pktinfo_addr.ip_address, ai.ip_port)