ruby-changes:54791
From: eregon <ko1@a...>
Date: Tue, 5 Feb 2019 18:58:54 +0900 (JST)
Subject: [ruby-changes:54791] eregon:r67010 (trunk): Make sure to wait with IO.select before using Socket#recvfrom_nonblock
eregon 2019-02-05 18:58:50 +0900 (Tue, 05 Feb 2019) New Revision: 67010 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67010 Log: Make sure to wait with IO.select before using Socket#recvfrom_nonblock * On all platforms, as this is the recommended code pattern. Modified files: trunk/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb Index: spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb =================================================================== --- spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb (revision 67009) +++ spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb (revision 67010) @@ -36,12 +36,11 @@ describe 'Socket#recvfrom_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb#L36 describe 'with data available' do before do @client.write('hello') - - platform_is(:darwin, :freebsd) { IO.select([@server]) } end platform_is_not :windows do it 'returns an Array containing the data and an Addrinfo' do + IO.select([@server]) ret = @server.recvfrom_nonblock(1) ret.should be_an_instance_of(Array) @@ -54,8 +53,7 @@ describe 'Socket#recvfrom_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb#L53 5.times do @client.write('hello') - platform_is(:darwin, :freebsd) { IO.select([@server]) } - + IO.select([@server]) msg, _ = @server.recvfrom_nonblock(5) msg.should == 'hello' @@ -66,6 +64,7 @@ describe 'Socket#recvfrom_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb#L64 platform_is_not :windows do describe 'the returned Array' do before do + IO.select([@server]) @array = @server.recvfrom_nonblock(1) end @@ -80,6 +79,7 @@ describe 'Socket#recvfrom_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb#L79 describe 'the returned Addrinfo' do before do + IO.select([@server]) @addr = @server.recvfrom_nonblock(1)[1] end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/