|
|
c4dea8 |
From 920b924e5652884064a9529ffbd80d458a46fbc6 Mon Sep 17 00:00:00 2001
|
|
|
c4dea8 |
From: eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
|
|
|
c4dea8 |
Date: Tue, 5 Feb 2019 09:58:50 +0000
|
|
|
c4dea8 |
Subject: [PATCH] Make sure to wait with IO.select before using
|
|
|
c4dea8 |
Socket#recvfrom_nonblock
|
|
|
c4dea8 |
|
|
|
c4dea8 |
* On all platforms, as this is the recommended code pattern.
|
|
|
c4dea8 |
|
|
|
c4dea8 |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
c4dea8 |
---
|
|
|
c4dea8 |
spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb | 8 ++++----
|
|
|
c4dea8 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
c4dea8 |
|
|
|
c4dea8 |
diff --git a/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb
|
|
|
c4dea8 |
index c1239ae637e0..74fd286c42ad 100644
|
|
|
c4dea8 |
--- a/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb
|
|
|
c4dea8 |
+++ b/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb
|
|
|
c4dea8 |
@@ -36,12 +36,11 @@
|
|
|
c4dea8 |
describe 'with data available' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
@client.write('hello')
|
|
|
c4dea8 |
-
|
|
|
c4dea8 |
- platform_is(:darwin, :freebsd) { IO.select([@server]) }
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
platform_is_not :windows do
|
|
|
c4dea8 |
it 'returns an Array containing the data and an Addrinfo' do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
ret = @server.recvfrom_nonblock(1)
|
|
|
c4dea8 |
|
|
|
c4dea8 |
ret.should be_an_instance_of(Array)
|
|
|
c4dea8 |
@@ -54,8 +53,7 @@
|
|
|
c4dea8 |
5.times do
|
|
|
c4dea8 |
@client.write('hello')
|
|
|
c4dea8 |
|
|
|
c4dea8 |
- platform_is(:darwin, :freebsd) { IO.select([@server]) }
|
|
|
c4dea8 |
-
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
msg, _ = @server.recvfrom_nonblock(5)
|
|
|
c4dea8 |
|
|
|
c4dea8 |
msg.should == 'hello'
|
|
|
c4dea8 |
@@ -66,6 +64,7 @@
|
|
|
c4dea8 |
platform_is_not :windows do
|
|
|
c4dea8 |
describe 'the returned Array' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@array = @server.recvfrom_nonblock(1)
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
@@ -80,6 +79,7 @@
|
|
|
c4dea8 |
|
|
|
c4dea8 |
describe 'the returned Addrinfo' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@addr = @server.recvfrom_nonblock(1)[1]
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
From c1f0daeb6ac5c5414c9a4a58bb778a118006ae1f Mon Sep 17 00:00:00 2001
|
|
|
c4dea8 |
From: eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
|
|
|
c4dea8 |
Date: Tue, 5 Feb 2019 10:19:29 +0000
|
|
|
c4dea8 |
Subject: [PATCH] Make sure to wait with IO.select before using
|
|
|
c4dea8 |
Socket#accept_nonblock and recvfrom_nonblock
|
|
|
c4dea8 |
|
|
|
c4dea8 |
* On all platforms, as this is the recommended code pattern.
|
|
|
c4dea8 |
|
|
|
c4dea8 |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
c4dea8 |
---
|
|
|
c4dea8 |
spec/ruby/library/socket/socket/accept_nonblock_spec.rb | 4 ++--
|
|
|
c4dea8 |
spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb | 5 +++--
|
|
|
c4dea8 |
2 files changed, 5 insertions(+), 4 deletions(-)
|
|
|
c4dea8 |
|
|
|
c4dea8 |
diff --git a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
|
|
|
c4dea8 |
index 3ef219ed05a9..cde9e6a4b669 100644
|
|
|
c4dea8 |
--- a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
|
|
|
c4dea8 |
+++ b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
|
|
|
c4dea8 |
@@ -86,8 +86,6 @@
|
|
|
c4dea8 |
@client = Socket.new(family, :STREAM, 0)
|
|
|
c4dea8 |
|
|
|
c4dea8 |
@client.connect(addr)
|
|
|
c4dea8 |
-
|
|
|
c4dea8 |
- platform_is(:darwin, :freebsd, :solaris) { IO.select([@server]) }
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
after do
|
|
|
c4dea8 |
@@ -96,6 +94,7 @@
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
it 'returns an Array containing a Socket and an Addrinfo' do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@socket, addrinfo = @server.accept_nonblock
|
|
|
c4dea8 |
|
|
|
c4dea8 |
@socket.should be_an_instance_of(Socket)
|
|
|
c4dea8 |
@@ -104,6 +103,7 @@
|
|
|
c4dea8 |
|
|
|
c4dea8 |
describe 'the returned Addrinfo' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@socket, @addr = @server.accept_nonblock
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
diff --git a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb
|
|
|
c4dea8 |
index 015109a05200..62bbaf0dc93a 100644
|
|
|
c4dea8 |
--- a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb
|
|
|
c4dea8 |
+++ b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb
|
|
|
c4dea8 |
@@ -40,16 +40,16 @@
|
|
|
c4dea8 |
describe 'with data available' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
@client.write('hello')
|
|
|
c4dea8 |
-
|
|
|
c4dea8 |
- platform_is(:darwin, :freebsd) { IO.select([@server]) }
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
it 'returns an Array containing the data and an Array' do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@server.recvfrom_nonblock(1).should be_an_instance_of(Array)
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
describe 'the returned Array' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@array = @server.recvfrom_nonblock(1)
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|
|
|
c4dea8 |
@@ -64,6 +64,7 @@
|
|
|
c4dea8 |
|
|
|
c4dea8 |
describe 'the returned address Array' do
|
|
|
c4dea8 |
before do
|
|
|
c4dea8 |
+ IO.select([@server])
|
|
|
c4dea8 |
@addr = @server.recvfrom_nonblock(1)[1]
|
|
|
c4dea8 |
end
|
|
|
c4dea8 |
|