-
- Downloads
Atomic writes, and long writes, to pipes.
This patch fixes two behaviors of pipes and unix-domain stream socketpair, which went against Posix and Linux standards 1. A blocking write() on a pipe needs to return only when the full write - is finished. It should not just write until the end of the pipe buffer and return - as we did in the previous code. This means that a long write() to a pipe can write the data in parts, waiting between them for a reader to read from the pipe. 2. As explained above, writes will be split into parts (and if there are multiple writers, get mixed with writes from other writers). But Posix also guarantees that short writes - up to 4096 bytes (PIPE_BUF==4096 on Linux) - are *atomic*, and not be split up. In the previous code, if even 1 byte was available on the buffer, we wrote it. Now, if the write is short, we need to wait until the entire needed length is available.
Please register or sign in to comment