[libvirt] [PATCH] Fix sending/receiving of FDs when stream returns EAGAIN

Eric Blake eblake at redhat.com
Fri Nov 4 21:45:42 UTC 2011


On 11/04/2011 10:06 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange"<berrange at redhat.com>
>
> The code calling sendfd/recvfd was mistakenly assuming those
> calls would never block. They can in fact return EAGAIN and
> this is causing us to drop the client connection when blocking
> ocurrs while sending/receiving FDs.
>
> Fixing this is a little hairy on the incoming side, since at
> the point where we see the EAGAIN, we already thought we had
> finished receiving all data for the packet. So we play a little
> trick to reset bufferOffset again and go back into polling for
> more data.
>
> * src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Update
>    virNetSocketSendFD/RecvFD to return 0 on EAGAIN, or 1
>    on success
> * src/rpc/virnetclient.c: Move decoding of header&  fds
>    out of virNetClientCallDispatch and into virNetClientIOHandleInput.
>    Handling blocking when sending/receiving FDs
> * src/rpc/virnetmessage.h: Add a 'donefds' field to track
>    how many FDs we've sent / received
> * src/rpc/virnetserverclient.c: Handling blocking when
>    sending/receiving FDs
> ---

ACK - the solution matches the commit message, which does sound like the 
correct way to handle things; and I didn't see anything wrong in the 
patch.  Appropriate for 0.9.7.

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




More information about the libvir-list mailing list