From: timsuth@... (Tim Sutherland) Date: 2005-01-21T20:01:02+09:00 Subject: Re: ruby-dev summary 25373-25479 In article <35ao47F4ifd7uU1@individual.net>, Florian Gross wrote: >Masayoshi Takahashi wrote: > >> [ruby-dev:25430] 1.8 warn nonblocking IO#read and add IO#readpartial >> >> Akr suggested to make changes of IO in ruby 1.8: >> >> * warn when you use nonblocking IO#read >> * add a new method IO#readpartial > >Does anybody know what is wrong with these? Are they not working >correctly or will non-blocking IO be deprecated in general? > >Thank you for the summary. See [ruby-talk:95953]. IO#read uses stdio which doesn't know about non-blocking, so data can be lost. IO#sysread is a safe alternative if non-blocking IO is used. The only place I'm aware of where non-blocking IO is useful in Ruby is for sockets when calling accept(). (There's a race condition if we just rely on select() saying someone's a-knockin': the client can leave between when select() returns and accept() is called. If blocking sockets are used the call to accept() can then block and no other threads can run. I'm not sure if the socket library actually does deal with this...)