ruby-changes:54792
From: eregon <ko1@a...>
Date: Tue, 5 Feb 2019 19:19:34 +0900 (JST)
Subject: [ruby-changes:54792] eregon:r67011 (trunk): Make sure to wait with IO.select before using Socket#accept_nonblock and recvfrom_nonblock
eregon 2019-02-05 19:19:29 +0900 (Tue, 05 Feb 2019) New Revision: 67011 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67011 Log: Make sure to wait with IO.select before using Socket#accept_nonblock and recvfrom_nonblock * On all platforms, as this is the recommended code pattern. Modified files: trunk/spec/ruby/library/socket/socket/accept_nonblock_spec.rb trunk/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb Index: spec/ruby/library/socket/socket/accept_nonblock_spec.rb =================================================================== --- spec/ruby/library/socket/socket/accept_nonblock_spec.rb (revision 67010) +++ spec/ruby/library/socket/socket/accept_nonblock_spec.rb (revision 67011) @@ -86,8 +86,6 @@ describe 'Socket#accept_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/accept_nonblock_spec.rb#L86 @client = Socket.new(family, :STREAM, 0) @client.connect(addr) - - platform_is(:darwin, :freebsd, :solaris) { IO.select([@server]) } end after do @@ -96,6 +94,7 @@ describe 'Socket#accept_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/accept_nonblock_spec.rb#L94 end it 'returns an Array containing a Socket and an Addrinfo' do + IO.select([@server]) @socket, addrinfo = @server.accept_nonblock @socket.should be_an_instance_of(Socket) @@ -104,6 +103,7 @@ describe 'Socket#accept_nonblock' do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/socket/accept_nonblock_spec.rb#L103 describe 'the returned Addrinfo' do before do + IO.select([@server]) @socket, @addr = @server.accept_nonblock end Index: spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb =================================================================== --- spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb (revision 67010) +++ spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb (revision 67011) @@ -40,16 +40,16 @@ describe 'UDPSocket#recvfrom_nonblock' d https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb#L40 describe 'with data available' do before do @client.write('hello') - - platform_is(:darwin, :freebsd) { IO.select([@server]) } end it 'returns an Array containing the data and an Array' do + IO.select([@server]) @server.recvfrom_nonblock(1).should be_an_instance_of(Array) end describe 'the returned Array' do before do + IO.select([@server]) @array = @server.recvfrom_nonblock(1) end @@ -64,6 +64,7 @@ describe 'UDPSocket#recvfrom_nonblock' d https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb#L64 describe 'the returned address Array' do before do + IO.select([@server]) @addr = @server.recvfrom_nonblock(1)[1] end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/