[libvirt] [PATCH v4 15/23] utils: Write a maximum of MAX_PIPE_WRITE_BYTES into a pipe

Daniel P. Berrangé berrange at redhat.com
Fri Jul 12 08:23:36 UTC 2019


On Thu, Jul 11, 2019 at 03:41:43PM -0400, Stefan Berger wrote:
> To avoid blocking on a write on a pipe that the receiving process
> does not read from, write only MAX_PIPE_WRITE_BYTES into the pipe
> so that we can serve other pipes as well.

This doesn't work. The pipe can have 1025 bytes free space, so you'll
write 1024 bytes first fine, and next iteration there'll be one byte
free space and you'll block. If you need to avoid blocking you must
use O_NONBLOCK on the fd. Don't try to guess how much you can write,
just write until you get EAGAIN.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list