[#83096] File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?}) — Nobuyoshi Nakada <nobu@...>
On 2017/10/04 8:47, normal@ruby-lang.org wrote:
5 messages
2017/10/04
[#83100] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Eric Wong <normalperson@...>
2017/10/04
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#83105] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Nobuyoshi Nakada <nobu@...>
2017/10/04
On 2017/10/04 15:55, Eric Wong wrote:
[#83107] Alias Enumerable#include? to Enumerable#includes? — Alberto Almagro <albertoalmagro@...>
Hello,
9 messages
2017/10/04
[#83113] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/05
This has been requested countless times, then rejected each and every time.
[#83129] Re: Alias Enumerable#include? to Enumerable#includes?
— Alberto Almagro <albertoalmagro@...>
2017/10/05
Sorry I didn't found it on the core mail list's archive.
[#83138] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/06
Ruby has not been made of popular votes so far. You have to show us
[#83149] Re: Alias Enumerable#include? to Enumerable#includes?
— Eric Wong <normalperson@...>
2017/10/06
Alberto Almagro <albertoalmagro@gmail.com> wrote:
[#83200] [Ruby trunk Feature#13996] [PATCH] file.c: apply2files releases GVL — normalperson@...
Issue #13996 has been reported by normalperson (Eric Wong).
4 messages
2017/10/10
[ruby-core:83181] [Ruby trunk Bug#12674][Rejected] io/wait: not handling the case when the socket is closed before doing wait_readable/writable with timeout
From:
nobu@...
Date:
2017-10-09 02:51:57 UTC
List:
ruby-core #83181
Issue #12674 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Assigned to Rejected
`IO#wait_readable` should return the receiver at EOF, since 2.3.
`nil` before EOF is the behavior of the OS.
----------------------------------------
Bug #12674: io/wait: not handling the case when the socket is closed before doing wait_readable/writable with timeout
https://bugs.ruby-lang.org/issues/12674#change-67122
* Author: chucke (Tiago Cardoso)
* Status: Rejected
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version:
* ruby -v:
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I wrote the following script to show the problem:
```ruby
require 'socket'
require 'io/wait'
Thread.new do
server = TCPServer.new 2000 # Server bind to port 2000
loop do
client = server.accept # Wait for a client to connect
client.puts "Hello !"
client.puts "Time is #{Time.now}"
sleep 3
client.close
end
end
puts "server is starting..."
sleep 2
puts "connecting now"
s = TCPSocket.new 'localhost', 2000
puts "connected"
10.times do
k = s.wait_readable(2)
puts "wait: #{k.inspect}"
v = s.read_nonblock(8, exception: false)
puts "val: #{v.inspect}"
break if v == nil
end
# server is starting...
# connecting now
# connected
# wait: #<TCPSocket:fd 11>
# val: "Hello !\n"
# wait: #<TCPSocket:fd 11>
# val: "Time is "
# wait: #<TCPSocket:fd 11>
# val: "2016-08-"
# wait: #<TCPSocket:fd 11>
# val: "14 16:30"
# wait: #<TCPSocket:fd 11>
# val: ":35 +020"
# wait: #<TCPSocket:fd 11>
# val: "0\n"
# wait: nil
# val: :wait_readable
# ISSUE!
# wait: nil
# val: nil
```
The problem there is, I'm going to `wait_readable(timeout)` on the socket, and it's going to return nil. This nil is ambiguous, as it can mean in the spec "timed out on wait" or "server has closed the socket". The only way I have to know exactly what it means is to call read_nonblock again. If nil, it's EOF. If wait_readable, it timed out. So I can't fail early.
The wait methods could benefit from a more explicit return value for #wait. This might have been subject to discussion previously, as "false" was removed as of ruby 2.3 from the possible return values, but I think it's an issue that might prevent correctness in socket programming. Take the example from the standard library: https://github.com/ruby/ruby/blob/trunk/lib/net/protocol.rb#L154-L159
If the server closes after :wait_readable was returned, wait_readable will return nil, and this will be interpreted as a timeout, instead of EOF. I don't know of any real-world issues with this using net/http, but there was one [here](https://github.com/httprb/http/issues/298).
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>