[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH RESEND] command: avoid fd leak on failure

On 10/13/2011 03:03 AM, Daniel Veillard wrote:
On Wed, Oct 12, 2011 at 05:59:40PM -0600, Eric Blake wrote:
virCommandTransferFD promises that the fd is no longer owned by
the caller.  Normally, we want the fd to remain open until the
child runs, but in error situations, we must close it earlier.

* src/util/command.c (virCommandTransferFD): Close fd now if we
can't track it to close later.
(virCommandKeepFD): Adjust helper to make this easier.

This leak can only happen on OOM or other extreme error conditions,
but ought to be plugged.  When I originally posted this:
DV was worried that callers might abuse things and use fd
even after this function closed it; but I proved to myself in
writing a (non-working) v2 that all callers were already safe,
and that this v1 was indeed a smaller solution.

   Okidoc then :-)


Thanks; pushed.

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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]