On 07/07/2011 08:17 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berra...@redhat.com>
> 
> * src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add
>   virNetSocketDupFD()
> * src/rpc/virnetclient.c, src/rpc/virnetclient.h: Add
>   virNetClientDupFD() and virNetClientGetFD()
> ---
>  src/rpc/virnetclient.c |   20 ++++++++++++++++++++
>  src/rpc/virnetclient.h |    3 +++
>  src/rpc/virnetsocket.c |   12 ++++++++++++
>  src/rpc/virnetsocket.h |    2 ++
>  4 files changed, 37 insertions(+), 0 deletions(-)

In the interest of using atomic FD_CLOEXEC in more places, I would
suggest making a change to this API:

> +
> +int virNetClientDupFD(virNetClientPtr client)

This should be virNetClientDupFD(virNetClientPtr client, bool cloexec)

>  
> +int virNetSocketDupFD(virNetSocketPtr sock)
> +{
> +    int fd;
> +    if ((fd = dup(sock->fd)) < 0) {

And this should be:

int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec)
{
    int fd;
    if (cloexec)
        fd = fcntl(F_DUPFD_CLOEXEC, sock->fd);
    else
        fd = dup(sock->fd);
    if (fd < 0) {
...

and rely on gnulib's guarantee that fcntl(F_DUPFD_CLOEXEC) works.  (Oh,
that means we need to import the fcntl module in bootstrap.conf).

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

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to