From: Joel VanderWerf Date: 2009-07-15T01:23:46+09:00 Subject: Re: Process.fork weirdness Brian Candler wrote: > Joel VanderWerf wrote: >> But what about a library using IO#write to talk http, a rest >> client, let's say? This would not want IO#sync=true. It might not >> really be possible to make the library aware of the need for >> synchronization around buffered writes. > > I don't think you'd have stdio-type buffering on a socket. At least, I > don't find that I have to do sock.flush every time I send a message. Ah, that makes sense. It would be only the libc and ruby buffers (in user space) that would get copied in the fork, not network stack buffers in kernel space. But wait... Net:HTTP uses BufferedIO#writeline on sockets. That class doesn't itself buffer writes (only reads), but it is defined in terms of IO#write, which is buffered, isn't it? I guess the reason buffering makes sense with Net::HTTP, as opposed to most other socket code, is that it writes header lines one at a time. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407