On 06/22/2012 12:36 PM, Corey Bryant wrote: > This patch adds the pass-fd QMP command using the QAPI framework. > Like the getfd command, it is used to pass a file descriptor via > SCM_RIGHTS and associate it with a name. However, the pass-fd > command also returns the received file descriptor, which is a > difference in behavior from the getfd command, which returns > nothing. pass-fd also supports a boolean "force" argument that > can be used to specify that an existing file descriptor is > associated with the specified name, and that it should become a > copy of the newly passed file descriptor. > + if (replace) { > + /* the existing fd is replaced with the new fd */ > + close(monfd->fd); > + monfd->fd = fd; > + return fd; > + } > + > + if (copy) { Since 'replace' and 'copy' are never both true, should this instead be a tri-state enum argument instead of two independent bool arguments? > + /* the existing fd becomes a copy of the new fd */ > + if (dup2(fd, monfd->fd) == -1) { Broken - you want to use dup3(fd, monfd->fd, O_CLOEXEC) (and fall back to dup2()+fcntl(F_GETFD/F_SETFD) on platforms where dup3 is not available; it has been proposed for the next revision of POSIX but right now is pretty much limited to Linux and Cygwin). Otherwise, you are undoing the fact that patch 1/7 just changed the 'getfd' list to always keep all its fds marked cloexec. -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list