From: Eric Wong Date: 2011-08-02T09:26:55+09:00 Subject: [ruby-core:38682] Re: [Ruby 1.9 - Bug #5138][Open] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK Urabe Shyouhei wrote: > (08/02/2011 08:48 AM), Eric Wong wrote: > > Urabe Shyouhei wrote: > >> (08/02/2011 08:35 AM), Eric Wong wrote: > >>> Urabe Shyouhei wrote: > >>>> (08/02/2011 08:14 AM), Eric Wong wrote: > >>>>> Urabe Shyouhei wrote: > >>>>>> So when you do a read loop, nothing bothers you, as long as you use > >>>>>> readpartial. > >>>>> > >>>>> That use of select + readpartial is unsafe. > >>>> > >>>> Unsafe how? readpatial works even without no data on a buffer. > >>> > >>> readpartial will block if there's no data readable, potentially freezing > >>> the whole process. > >> > >> Yes but that's not catastrophic. The peer side is sending a data anyway. > >> Checksum incorrect packets are dropped but retransmitted sooner or later. > >> The process blocks during that retransmission. That won't last so long. > > > > Malicious clients can take advantage of this to launch a denial-of-service > > attack > > ... even when you do a blocking IO. TCP's having problems on malicious > clients is a known issue of the protocol I think. Yes, but I think one should be as defensive-as-possible for these things. > > Also, networks should never be considered reliable and simple > > operations can fail or take a long time. > > is that the problem we are talking about here? Does Yehuda need a DoS- > proven read loop? or he just want a fast variant of read_nonblock? I don't know what Yehuda needs, but code proliferates and I would hate to see reliance on fragile assumptions badly affect something down the line that went beyond Yehuda's original need. -- Eric Wong