Re: [PATCH] safe{read, write}: Don't lie on nonblocking FD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 16, 2013 at 07:39:53PM +0100, Michal Privoznik wrote:
> On 16.01.2013 19:31, Daniel P. Berrange wrote:
> > On Wed, Jan 16, 2013 at 07:27:46PM +0100, Michal Privoznik wrote:
> >> Currently, whenever somebody calls saferead() on nonblocking FD
> >> (safewrite() is totally interchangeable for purpose of this
> >> message) he might get wrong return value. For instance, in the
> >> first iteration some data is read. The number of bytes read is
> >> stored into local variable 'nread'. However, in next iterations
> >> we can get -1 from read() with errno == EAGAIN, in which case the
> >> -1 is returned despite fact some data has already been read. So
> >> the caller gets confused.
> >>
> >> Moreover, the comment just above the functions says, they act
> >> like regular read() with nicer handling of EINTR. Well, they
> >> don't now.
> > 
> > I think that it is correct that these APIs return -1 on EAGAIN.
> > These APIs should *not* be used on non-blocking FDs.
> > 
> In that case I think we have to note it explicitly in the comments.

BTW, what code did you encounter that was using this with non-blocking
fds ?

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]