]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Always close drivers when a virConnectPtr is released
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 24 Nov 2010 17:10:14 +0000 (18:10 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 24 Nov 2010 21:48:36 +0000 (22:48 +0100)
commitd8b367496eed774e317531898016613b1093d9cd
tree2821cc86e29c6b61aae51ea77b0d4e7efe0c223b
parentf3605b33a1289302f62c148fa0d96d17772f970c
Always close drivers when a virConnectPtr is released

virConnectClose calls virUnrefConnect which in turn closes
all open drivers when the refcount of that connection dropped
to zero. This works fine when you free all other objects that
hold a ref to the connection before you close it, because in
this case virUnrefConnect is the one that removes the last
ref to the connection.

But it doesn't work when you close the connection first before
freeing the other objects. This is because the other virUnref*
functions call virReleaseConnect when they detect that the
connection's refcount dropped to zero. In this case another
virUnref* function (different from virUnrefConnect) removes the
last ref to the connection. This results in not closing the
open drivers and leaking things that should have been cleaned
up in the driver close functions.

To fix this move the driver close calls to virReleaseConnect.
src/datatypes.c