Re: [PATCH] safe{read, write}: Document usage with nonblocking FD

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

 



On 17.01.2013 10:43, Daniel P. Berrange wrote:
> On Thu, Jan 17, 2013 at 08:55:14AM +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.
>> Bare read() should be used for nonblocking FD.
>> ---
>>  src/util/virutil.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>

> 
> ACK
> 
> Or even use virSocket() if the FD is related to a socket rather than a
> plain file or pipe.
> 
> Daniel
> 

I've used that sentence and pushed. Thanks.

Michal

--
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]