grnet/libxseg — pull request #20 by cnanakos (2014-10-10 14:37:33+00:00)
Title: xseg_posixfd: Refactor FIFO creation & pipe ops

* Remove retry loop in FIFO creation. If FIFO already exist's
do not unlink and re-create the named pipe. Also note that
mkfifo() is thread-safe and async-cancel-safe.

* As it happens with pipes, writing to a FIFO with no connected
readers will fail with EPIPE and also deliver a SIGPIPE signal
to the writer. Reading from a FIFO with no connected writers will
return an EOF to the reader. Setting the O_RDWR flag while opening
the pipe will create an equal number of connected readers/writers
to the kernel and will ensure that both are above zero.
This implementation will NEVER block since the process can at least
talk to itself.
** POSIX.1 leaves this case "undefined" when O_NONBLOCK is set. **

* Drain the pipe even if the call was interrupted by a signal
before any data was read. Optimize drain loop to make the
minimum number of read syscall's.

* Write to the pipe even if the call was interrupted by a signal
before any data was written.