[libvirt] [PATCHv2] build: use gnulib passfd for simpler SCM_RIGHTS code

Eric Blake eblake at redhat.com
Mon Apr 25 14:21:06 UTC 2011


On 04/25/2011 01:17 AM, Laine Stump wrote:
>> @@ -1529,26 +1513,20 @@ virFileOpenAs(const char *path, int openflags,
>> mode_t mode,
>>           VIR_FORCE_CLOSE(pair[1]);
>>
>>           do {
>> -            ret = recvmsg(pair[0],&msg, 0);
>> +            ret = recvfd(pair[0], 0);
>>           } while (ret<  0&&  errno == EINTR);

ret == -1 and errno == EACCES on failure to transfer fd...

>>
>> -        if (ret<  0) {
>> +        if (ret<  0&&  errno != EACCES) {
>>               ret = -errno;
>>               VIR_FORCE_CLOSE(pair[0]);
>>               while ((waitret = waitpid(pid, NULL, 0) == -1)
>>                      &&  (errno == EINTR));
>>               goto parenterror;
>> +        } else {
>> +            fd = ret;
>>           }

so now fd == -1...


>         if (!WIFEXITED(status) || (ret = -WEXITSTATUS(status)) == -EACCES ||
>             fd == -1) {
>             /* fall back to the simpler method, which works better in
>              * some cases */
>             return virFileOpenAsNoFork(path, openflags, mode, uid, gid, flags);
>         }

so this uses the fallback code, regardless of child exit status, and we
also ensured that the child got reaped.

> 
> What if errno == EACCES? Will we be getting all the error recovery we
> need in the caller?

Yes.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110425/1fd76edd/attachment-0001.sig>


More information about the libvir-list mailing list