From 21ddab65248436dd75e5d2d977301a0f55c50740 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Fri, 8 Jan 2016 18:24:20 +0100 Subject: [PATCH 01/12] adding RSpec namespace (3.4.0) doesn't contain the global space monkeypatch of .describe anymore --- spec/celluloid/io/actor_spec.rb | 2 +- spec/celluloid/io/dns_resolver_spec.rb | 2 +- spec/celluloid/io/mailbox_spec.rb | 2 +- spec/celluloid/io/ssl_server_spec.rb | 2 +- spec/celluloid/io/ssl_socket_spec.rb | 2 +- spec/celluloid/io/tcp_server_spec.rb | 2 +- spec/celluloid/io/tcp_socket_spec.rb | 2 +- spec/celluloid/io/udp_socket_spec.rb | 2 +- spec/celluloid/io/unix_server_spec.rb | 2 +- spec/celluloid/io/unix_socket_spec.rb | 2 +- spec/celluloid/io_spec.rb | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/celluloid/io/actor_spec.rb b/spec/celluloid/io/actor_spec.rb index e72364d..f77bdd7 100644 --- a/spec/celluloid/io/actor_spec.rb +++ b/spec/celluloid/io/actor_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Celluloid::IO do +RSpec.describe Celluloid::IO do it_behaves_like "a Celluloid Actor", Celluloid::IO end diff --git a/spec/celluloid/io/dns_resolver_spec.rb b/spec/celluloid/io/dns_resolver_spec.rb index 036ab1d..c50ac87 100644 --- a/spec/celluloid/io/dns_resolver_spec.rb +++ b/spec/celluloid/io/dns_resolver_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::DNSResolver do +RSpec.describe Celluloid::IO::DNSResolver do describe '#resolve' do it 'resolves hostnames' do resolver = Celluloid::IO::DNSResolver.new diff --git a/spec/celluloid/io/mailbox_spec.rb b/spec/celluloid/io/mailbox_spec.rb index 7a6109e..354baf5 100644 --- a/spec/celluloid/io/mailbox_spec.rb +++ b/spec/celluloid/io/mailbox_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Celluloid::IO::Mailbox do +RSpec.describe Celluloid::IO::Mailbox do it_behaves_like "a Celluloid Mailbox" end diff --git a/spec/celluloid/io/ssl_server_spec.rb b/spec/celluloid/io/ssl_server_spec.rb index 1a53f21..ee8e9b5 100644 --- a/spec/celluloid/io/ssl_server_spec.rb +++ b/spec/celluloid/io/ssl_server_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::SSLServer do +RSpec.describe Celluloid::IO::SSLServer do let(:client_cert) { OpenSSL::X509::Certificate.new fixture_dir.join("client.crt").read } let(:client_key) { OpenSSL::PKey::RSA.new fixture_dir.join("client.key").read } let(:client_context) do diff --git a/spec/celluloid/io/ssl_socket_spec.rb b/spec/celluloid/io/ssl_socket_spec.rb index 86df511..15e33fa 100644 --- a/spec/celluloid/io/ssl_socket_spec.rb +++ b/spec/celluloid/io/ssl_socket_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'openssl' -describe Celluloid::IO::SSLSocket do +RSpec.describe Celluloid::IO::SSLSocket do let(:request) { 'ping' } let(:response) { 'pong' } diff --git a/spec/celluloid/io/tcp_server_spec.rb b/spec/celluloid/io/tcp_server_spec.rb index e7577bd..ff4e912 100644 --- a/spec/celluloid/io/tcp_server_spec.rb +++ b/spec/celluloid/io/tcp_server_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::TCPServer do +RSpec.describe Celluloid::IO::TCPServer do describe "#accept" do let(:payload) { 'ohai' } diff --git a/spec/celluloid/io/tcp_socket_spec.rb b/spec/celluloid/io/tcp_socket_spec.rb index 82f84e1..00ae5a4 100644 --- a/spec/celluloid/io/tcp_socket_spec.rb +++ b/spec/celluloid/io/tcp_socket_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::TCPSocket do +RSpec.describe Celluloid::IO::TCPSocket do let(:payload) { 'ohai' } context "inside Celluloid::IO" do diff --git a/spec/celluloid/io/udp_socket_spec.rb b/spec/celluloid/io/udp_socket_spec.rb index d7d4769..38002a4 100644 --- a/spec/celluloid/io/udp_socket_spec.rb +++ b/spec/celluloid/io/udp_socket_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::UDPSocket do +RSpec.describe Celluloid::IO::UDPSocket do let(:payload) { 'ohai' } subject do Celluloid::IO::UDPSocket.new.tap do |sock| diff --git a/spec/celluloid/io/unix_server_spec.rb b/spec/celluloid/io/unix_server_spec.rb index a0f9fdc..4a7ebb0 100644 --- a/spec/celluloid/io/unix_server_spec.rb +++ b/spec/celluloid/io/unix_server_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::UNIXServer do +RSpec.describe Celluloid::IO::UNIXServer do describe "#accept" do before do pending "JRuby support" if defined?(JRUBY_VERSION) diff --git a/spec/celluloid/io/unix_socket_spec.rb b/spec/celluloid/io/unix_socket_spec.rb index 132d18d..28fab72 100644 --- a/spec/celluloid/io/unix_socket_spec.rb +++ b/spec/celluloid/io/unix_socket_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO::UNIXSocket do +RSpec.describe Celluloid::IO::UNIXSocket do before do pending "JRuby support" if defined?(JRUBY_VERSION) end diff --git a/spec/celluloid/io_spec.rb b/spec/celluloid/io_spec.rb index 47aa104..3bde222 100644 --- a/spec/celluloid/io_spec.rb +++ b/spec/celluloid/io_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Celluloid::IO do +RSpec.describe Celluloid::IO do context "copy_stream" do let(:host) { "127.0.0.1" } let(:port) { 23456 } From 5321f59b46c5b6475662befaa337c3668f9083d4 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Fri, 8 Jan 2016 18:26:42 +0100 Subject: [PATCH 02/12] using the new read_ and write_nonblock signature (ruby 2.1) in which one doesn't need to handle Wait* Exception (Closes #139) --- lib/celluloid/io/stream.rb | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/celluloid/io/stream.rb b/lib/celluloid/io/stream.rb index 19f50ce..31916f6 100644 --- a/lib/celluloid/io/stream.rb +++ b/lib/celluloid/io/stream.rb @@ -37,11 +37,15 @@ def sysread(length = nil, buffer = nil) buffer ||= ''.force_encoding(Encoding::ASCII_8BIT) @read_latch.synchronize do - begin - read_nonblock(length, buffer) - rescue ::IO::WaitReadable - wait_readable - retry + if RUBY_VERSION < '2.1' + begin + read_nonblock(length, buffer) + rescue ::IO::WaitReadable + wait_readable + retry + end + else + loop while read_nonblock(length, buffer, exception: false) == :wait_readable end end @@ -57,13 +61,21 @@ def syswrite(string) @write_latch.synchronize do while total_written < length - begin - written = write_nonblock(remaining) - rescue ::IO::WaitWritable - wait_writable - retry - rescue EOFError - return total_written + if RUBY_VERSION < '2.1' + begin + written = write_nonblock(remaining) + rescue ::IO::WaitWritable + wait_writable + retry + rescue EOFError + return total_written + end + else + begin + loop while (written = write_nonblock(remaining, exception: false)) == :wait_writable + rescue EOFError + return total_written + end end total_written += written From de715240e28faf697f27b22e9070b8289b78caa3 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Fri, 8 Jan 2016 20:37:53 +0100 Subject: [PATCH 03/12] adapted the code from the http gem according to tarcieri's suggestion and using it to encapsulate nonblock reads and writes inside the streams --- lib/celluloid/io/stream.rb | 61 +++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/lib/celluloid/io/stream.rb b/lib/celluloid/io/stream.rb index 9c5e070..60f8631 100644 --- a/lib/celluloid/io/stream.rb +++ b/lib/celluloid/io/stream.rb @@ -38,16 +38,8 @@ def sysread(length = nil, buffer = nil) buffer ||= ''.force_encoding(Encoding::ASCII_8BIT) @read_latch.synchronize do - if RUBY_VERSION < '2.1' - begin - read_nonblock(length, buffer) - rescue ::IO::WaitReadable - wait_readable - retry - end - else - loop while read_nonblock(length, buffer, exception: false) == :wait_readable - end + op = perform_io { read_nonblock(length, buffer) } + raise EOFError if op == :eof end buffer @@ -62,29 +54,8 @@ def syswrite(string) @write_latch.synchronize do while total_written < length - if RUBY_VERSION < '2.1' - begin - written = write_nonblock(remaining) - rescue ::IO::WaitWritable - wait_writable - retry - rescue EOFError - return total_written - rescue Errno::EAGAIN - wait_writable - retry - end - else - begin - loop while (written = write_nonblock(remaining, exception: false)) == :wait_writable - rescue EOFError - return total_written - # is this really needed????? - rescue Errno::EAGAIN - wait_writable - retry - end - end + written = perform_io { write_nonblock(remaining) } + return total_written if written == :eof total_written += written @@ -333,6 +304,30 @@ def close private ####### + def perform_io + loop do + begin + result = yield + + case result + when :wait_readable then wait_readable + when :wait_writable then wait_writable + when NilClass then return :eof + else return result + end + rescue ::IO::WaitReadable + wait_readable + retry + rescue ::IO::WaitWritable, + Errno::EAGAIN + wait_writable + retry + end + end + rescue EOFError + :eof + end + # Fills the buffer from the underlying stream def fill_rbuff begin From f4160d6f5c1f111de73d315bbda344ecba5c64bf Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Mon, 11 Jan 2016 14:53:11 +0100 Subject: [PATCH 04/12] moving the #perform_io to the socket base class, so that udp can use it --- lib/celluloid/io/socket.rb | 26 ++++++++++++++++++++++++++ lib/celluloid/io/stream.rb | 24 ------------------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/celluloid/io/socket.rb b/lib/celluloid/io/socket.rb index 9bd369a..3b00c47 100644 --- a/lib/celluloid/io/socket.rb +++ b/lib/celluloid/io/socket.rb @@ -70,6 +70,32 @@ def self.try_convert(socket, convert_io = true) end end + private + + def perform_io + loop do + begin + result = yield + + case result + when :wait_readable then wait_readable + when :wait_writable then wait_writable + when NilClass then return :eof + else return result + end + rescue ::IO::WaitReadable + wait_readable + retry + rescue ::IO::WaitWritable, + Errno::EAGAIN + wait_writable + retry + end + end + rescue EOFError + :eof + end + class << self extend Forwardable def_delegators '::Socket', *(::Socket.methods - self.methods - [:try_convert]) diff --git a/lib/celluloid/io/stream.rb b/lib/celluloid/io/stream.rb index 60f8631..8f473ef 100644 --- a/lib/celluloid/io/stream.rb +++ b/lib/celluloid/io/stream.rb @@ -304,30 +304,6 @@ def close private ####### - def perform_io - loop do - begin - result = yield - - case result - when :wait_readable then wait_readable - when :wait_writable then wait_writable - when NilClass then return :eof - else return result - end - rescue ::IO::WaitReadable - wait_readable - retry - rescue ::IO::WaitWritable, - Errno::EAGAIN - wait_writable - retry - end - end - rescue EOFError - :eof - end - # Fills the buffer from the underlying stream def fill_rbuff begin From ecdd882a81af5a4c8ef14710ab4521fbb6ccf0fa Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Mon, 11 Jan 2016 15:30:44 +0100 Subject: [PATCH 05/12] encapsulating nonblock usage for UDPSockets within the #perform_io method --- lib/celluloid/io/udp_socket.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/celluloid/io/udp_socket.rb b/lib/celluloid/io/udp_socket.rb index b2edc36..c1e324a 100644 --- a/lib/celluloid/io/udp_socket.rb +++ b/lib/celluloid/io/udp_socket.rb @@ -31,18 +31,15 @@ def wait_readable; Celluloid::IO.wait_readable(self); end # MSG_ options. The first element of the results, mesg, is the data # received. The second element, sender_addrinfo, contains # protocol-specific address information of the sender. - def recvfrom(maxlen, flags = 0) - begin + def recvfrom(*args) + perform_io do socket = to_io if socket.respond_to? :recvfrom_nonblock - socket.recvfrom_nonblock(maxlen, flags) + socket.recvfrom_nonblock(*args) else # FIXME: hax for JRuby - socket.recvfrom(maxlen, flags) + socket.recvfrom(*args) end - rescue ::IO::WaitReadable - wait_readable - retry end end From 13630b7096fc231fbaee86b2ed2ec75cd818af42 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Sun, 17 Jan 2016 01:07:32 +0100 Subject: [PATCH 06/12] adding exception: false option to the nonblocking APIs, except UDPSocket, as the arguments are directly passed and one should leverage it himself --- lib/celluloid/io/stream.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/celluloid/io/stream.rb b/lib/celluloid/io/stream.rb index 8f473ef..41934e0 100644 --- a/lib/celluloid/io/stream.rb +++ b/lib/celluloid/io/stream.rb @@ -38,7 +38,12 @@ def sysread(length = nil, buffer = nil) buffer ||= ''.force_encoding(Encoding::ASCII_8BIT) @read_latch.synchronize do - op = perform_io { read_nonblock(length, buffer) } + op = perform_io do + # TODO: remove after ending ruby 2.0.0 support + RUBY_VERSION < "2.1" ? + read_nonblock(length, buffer) : + read_nonblock(length, buffer, exception: false) + end raise EOFError if op == :eof end @@ -54,7 +59,12 @@ def syswrite(string) @write_latch.synchronize do while total_written < length - written = perform_io { write_nonblock(remaining) } + written = perform_io do + # TODO: remove after ending ruby 2.0.0 support + RUBY_VERSION < "2.1" ? + write_nonblock(remaining) : + write_nonblock(remaining, exception: false) + end return total_written if written == :eof total_written += written From d21ac9c95f1452eb883504ff8c832ce662d6d7a1 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Mon, 18 Jan 2016 13:03:37 +0100 Subject: [PATCH 07/12] adding the exception: false option when using the udp socket to perform dns queries (this one is only compatible with ruby 2.3.0) --- lib/celluloid/io/dns_resolver.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/celluloid/io/dns_resolver.rb b/lib/celluloid/io/dns_resolver.rb index 7def5b5..5f62255 100644 --- a/lib/celluloid/io/dns_resolver.rb +++ b/lib/celluloid/io/dns_resolver.rb @@ -42,7 +42,10 @@ def resolve(hostname) query = build_query(hostname) @socket.send query.encode, 0, @server.to_s, DNS_PORT - data, _ = @socket.recvfrom(MAX_PACKET_SIZE) + data, _ = RUBY_VERSION >= "2.3" ? + # Documenting the cryptic second parameter (flags): http://stackoverflow.com/questions/1527895/where-are-msg-options-defined-for-ruby-sockets + @socket.recvfrom(MAX_PACKET_SIZE, 0, nil, exception: false) : + @socket.recvfrom(MAX_PACKET_SIZE) response = Resolv::DNS::Message.decode(data) addrs = [] From b397086f8fd2654e3563bb87437e43baf2914ce5 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Mon, 18 Jan 2016 19:19:14 +0100 Subject: [PATCH 08/12] defining #recvfrom method in UDPSocket according to ruby version --- lib/celluloid/io/dns_resolver.rb | 5 +---- lib/celluloid/io/udp_socket.rb | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/celluloid/io/dns_resolver.rb b/lib/celluloid/io/dns_resolver.rb index 5f62255..7def5b5 100644 --- a/lib/celluloid/io/dns_resolver.rb +++ b/lib/celluloid/io/dns_resolver.rb @@ -42,10 +42,7 @@ def resolve(hostname) query = build_query(hostname) @socket.send query.encode, 0, @server.to_s, DNS_PORT - data, _ = RUBY_VERSION >= "2.3" ? - # Documenting the cryptic second parameter (flags): http://stackoverflow.com/questions/1527895/where-are-msg-options-defined-for-ruby-sockets - @socket.recvfrom(MAX_PACKET_SIZE, 0, nil, exception: false) : - @socket.recvfrom(MAX_PACKET_SIZE) + data, _ = @socket.recvfrom(MAX_PACKET_SIZE) response = Resolv::DNS::Message.decode(data) addrs = [] diff --git a/lib/celluloid/io/udp_socket.rb b/lib/celluloid/io/udp_socket.rb index c1e324a..e8c8b8c 100644 --- a/lib/celluloid/io/udp_socket.rb +++ b/lib/celluloid/io/udp_socket.rb @@ -31,14 +31,22 @@ def wait_readable; Celluloid::IO.wait_readable(self); end # MSG_ options. The first element of the results, mesg, is the data # received. The second element, sender_addrinfo, contains # protocol-specific address information of the sender. - def recvfrom(*args) - perform_io do + if RUBY_VERSION >= "2.3" + def recvfrom(*args, **options) socket = to_io - if socket.respond_to? :recvfrom_nonblock - socket.recvfrom_nonblock(*args) - else - # FIXME: hax for JRuby - socket.recvfrom(*args) + options[:exception] = false + perform_io { socket.recvfrom_nonblock(*args, **options) } + end + else + def recvfrom(*args) + socket = to_io + perform_io do + if socket.respond_to? :recvfrom_nonblock + socket.recvfrom_nonblock(*args) + else + # FIXME: hax for JRuby + socket.recvfrom(*args) + end end end end From d621577fdb369c1ff41a92f3e8f437767fbcf6bc Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Mon, 18 Jan 2016 19:27:40 +0100 Subject: [PATCH 09/12] redefining #read* and write_nonblock for ruby 2.1 or bigger; passing exception: false flag all the time --- lib/celluloid/io/stream.rb | 24 ++++++++++++++++-------- spec/celluloid/io/tcp_socket_spec.rb | 1 - 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/celluloid/io/stream.rb b/lib/celluloid/io/stream.rb index 41934e0..158626e 100644 --- a/lib/celluloid/io/stream.rb +++ b/lib/celluloid/io/stream.rb @@ -39,10 +39,7 @@ def sysread(length = nil, buffer = nil) @read_latch.synchronize do op = perform_io do - # TODO: remove after ending ruby 2.0.0 support - RUBY_VERSION < "2.1" ? - read_nonblock(length, buffer) : - read_nonblock(length, buffer, exception: false) + read_nonblock(length, buffer) end raise EOFError if op == :eof end @@ -60,10 +57,7 @@ def syswrite(string) @write_latch.synchronize do while total_written < length written = perform_io do - # TODO: remove after ending ruby 2.0.0 support - RUBY_VERSION < "2.1" ? - write_nonblock(remaining) : - write_nonblock(remaining, exception: false) + write_nonblock(remaining) end return total_written if written == :eof @@ -77,6 +71,20 @@ def syswrite(string) total_written end + # TODO: remove after ending ruby 2.0.0 support + if RUBY_VERSION >= "2.1" + def read_nonblock(*args, **options) + options[:exception] = false + super(*args, **options) + end + + def write_nonblock(*args, **options) + options[:exception] = false + super(*args, **options) + end + end + + # Reads +size+ bytes from the stream. If +buf+ is provided it must # reference a string which will receive the data. # diff --git a/spec/celluloid/io/tcp_socket_spec.rb b/spec/celluloid/io/tcp_socket_spec.rb index aaba86f..80b0fe2 100644 --- a/spec/celluloid/io/tcp_socket_spec.rb +++ b/spec/celluloid/io/tcp_socket_spec.rb @@ -188,7 +188,6 @@ with_connected_sockets(example_port) do |subject, peer| subject.sync = false within_io_actor { subject << payload } - expect{ peer.read_nonblock payload.length }.to raise_exception ::IO::WaitReadable within_io_actor { subject.close } expect(peer.read).to eq payload end From f68e55110705d8c9d4222f6e058447d21a878c59 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Mon, 18 Jan 2016 19:30:35 +0100 Subject: [PATCH 10/12] adding WaitReadable condition to spec only when ruby under 2.1 --- spec/celluloid/io/tcp_socket_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/celluloid/io/tcp_socket_spec.rb b/spec/celluloid/io/tcp_socket_spec.rb index 80b0fe2..6cc59e8 100644 --- a/spec/celluloid/io/tcp_socket_spec.rb +++ b/spec/celluloid/io/tcp_socket_spec.rb @@ -188,6 +188,9 @@ with_connected_sockets(example_port) do |subject, peer| subject.sync = false within_io_actor { subject << payload } + if RUBY_VERSION < "2.1" + expect{ peer.read_nonblock payload.length }.to raise_exception ::IO::WaitReadable + end within_io_actor { subject.close } expect(peer.read).to eq payload end From c85cac947c7cf21072fbcd25c37cfe1548e1e2fb Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Tue, 19 Jan 2016 11:15:55 +0100 Subject: [PATCH 11/12] use Timeout.timeout, ruby 2.3 is deprecating Kernel.timeout --- spec/celluloid/io/reactor_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/celluloid/io/reactor_spec.rb b/spec/celluloid/io/reactor_spec.rb index fcbf386..62886a6 100644 --- a/spec/celluloid/io/reactor_spec.rb +++ b/spec/celluloid/io/reactor_spec.rb @@ -17,7 +17,7 @@ # Main server body: within_io_actor do begin - timeout(2) do + Timeout.timeout(2) do loop do socket.readpartial(2046) end From 1e8b3d64dc56173f81f0ce55d6a1d65cfdc98dae Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Tue, 19 Jan 2016 11:16:51 +0100 Subject: [PATCH 12/12] making nonblock calls within celluloid streams exceptionless by default, unless someone is messing with the :exception option --- lib/celluloid/io/stream.rb | 4 ++-- lib/celluloid/io/udp_socket.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/celluloid/io/stream.rb b/lib/celluloid/io/stream.rb index 158626e..cd84cbc 100644 --- a/lib/celluloid/io/stream.rb +++ b/lib/celluloid/io/stream.rb @@ -74,12 +74,12 @@ def syswrite(string) # TODO: remove after ending ruby 2.0.0 support if RUBY_VERSION >= "2.1" def read_nonblock(*args, **options) - options[:exception] = false + options[:exception] = false unless options.has_key?(:exception) super(*args, **options) end def write_nonblock(*args, **options) - options[:exception] = false + options[:exception] = false unless options.has_key?(:exception) super(*args, **options) end end diff --git a/lib/celluloid/io/udp_socket.rb b/lib/celluloid/io/udp_socket.rb index e8c8b8c..05e6783 100644 --- a/lib/celluloid/io/udp_socket.rb +++ b/lib/celluloid/io/udp_socket.rb @@ -34,7 +34,7 @@ def wait_readable; Celluloid::IO.wait_readable(self); end if RUBY_VERSION >= "2.3" def recvfrom(*args, **options) socket = to_io - options[:exception] = false + options[:exception] = false unless options.has_key?(:exception) perform_io { socket.recvfrom_nonblock(*args, **options) } end else