On 27/08/09 at 07:57 +0200, Petr Salinger wrote: > Package: ruby1.9.1 > Tags: patch > User: [email protected] > Usertags: kfreebsd > > Hi, this is followup to #542927. > > The test #226 is: > > begin > require "io/nonblock" > r, w = IO.pipe > w.nonblock = true > w.write_nonblock("a" * 100000) > w.nonblock = false > t1 = Thread.new { w.write("b" * 4096) } > t2 = Thread.new { w.write("c" * 4096) } > sleep 0.5 > r.sysread(4096).length > sleep 0.5 > r.sysread(4096).length > t1.join > t2.join > rescue LoadError > end > > It fails randomly under GNU/kFreeBSD, similarly as on darwin, see > http://redmine.ruby-lang.org/issues/show/1066 > > This failure can be made permanent by adding sleep between "Thread.new": > > begin > require "io/nonblock" > r, w = IO.pipe > w.nonblock = true > w.write_nonblock("a" * 100000) > w.nonblock = false > t1 = Thread.new { w.write("b" * 4096) } > sleep 0.5 > t2 = Thread.new { w.write("c" * 4096) } > sleep 0.5 > r.sysread(4096).length > sleep 0.5 > r.sysread(4096).length > t1.join > t2.join > rescue LoadError > end > > > The test assumes that the kernel buffer for pipes have fixed size. > It does not have to be true, there could be adaptive buffer size > provided by kernel. After filling whole kernel buffer (by > non-blocking write), it might be required to buffer becomes filled > only from half > or even empty. The next write() might be blocked until whole kernel > buffer is read. Such behaviour of kernel is correct one. > > The kernel of FreeBSD uses adaptive pipe sizes and direct pipe writes, > see http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/sys_pipe.c > > IMO, the test is buggy, I suggest to change it into: > > begin > require "io/nonblock" > r, w = IO.pipe > w.nonblock = true > bytes = w.write_nonblock("a" * 100000) > w.nonblock = false > t1 = Thread.new { w.write("b" * 4096) } > t2 = Thread.new { w.write("c" * 4096) } > sleep 0.5 > blocks = 2 + bytes/4096 > blocks.times { > r.sysread(4096).length > sleep 0.1 > } > t1.join > t2.join > rescue LoadError > end > > Unfortunately, I don't understand what this should test. > > Please, could you forward it also upstream.
Hi Petr, Thanks a lot for the investigation. I've forwarded the bug upstream (http://redmine.ruby-lang.org/issues/show/2008). I will also disable the test on FreeBSD for now, since it is not clear what the test is trying to achieve anyway. -- | Lucas Nussbaum | [email protected] http://www.lucas-nussbaum.net/ | | jabber: [email protected] GPG: 1024D/023B3F4F | -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

