
On 03/11/2011 05:15 AM, Paolo Bonzini wrote:
On 03/11/2011 05:30 AM, Wen Congyang wrote:
Yep, makes sense. I'm double checking whether I reliably closed the write end of the socket in all paths, and it may boil down to changing the child to_always_ sendmsg even if there is no fd to send. I'm still thinking about it.
Using SOCK_STREAM instead of SOCK_DGRAM to create socketpair can resolve this problem. But I don't know why.
At least with AF_INET that would be obvious: with SOCK_STRAM exiting the child will close the connection. With a datagram socket, the parent can still wait for other messages to the same UDP port.
I have no idea whether things work the same for AF_UNIX, but apparently they do. :)
Not only does this fix the problem, the other uses of socketpair() in libvirt also use SOCKET_STREAM instead of SOCKET_DGRAM. So I'd say this is an acceptable fix.