Add a method for closing the dbus system bus connection

If the dbus system bus connection is marked as private, then
allow it to be closed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-10-11 15:57:05 +01:00
parent 0cb774f051
commit 489beb0aba
3 changed files with 14 additions and 0 deletions

View File

@ -1102,6 +1102,7 @@ virConfWriteMem;
# util/virdbus.h
virDBusCallMethod;
virDBusCloseSystemBus;
virDBusGetSessionBus;
virDBusGetSystemBus;
virDBusHasSystemBus;

View File

@ -122,6 +122,14 @@ virDBusHasSystemBus(void)
}
void virDBusCloseSystemBus(void)
{
if (systembus && !sharedBus) {
dbus_connection_close(systembus);
systembus = NULL;
}
}
static void virDBusSessionBusInit(void)
{
sessionbus = virDBusBusInit(DBUS_BUS_SESSION, &sessiondbuserr);
@ -1310,6 +1318,10 @@ virDBusHasSystemBus(void)
return false;
}
void virDBusCloseSystemBus(void)
{
/* nothing */
}
DBusConnection *virDBusGetSessionBus(void)
{

View File

@ -35,6 +35,7 @@ void virDBusSetSharedBus(bool shared);
DBusConnection *virDBusGetSystemBus(void);
bool virDBusHasSystemBus(void);
void virDBusCloseSystemBus(void);
DBusConnection *virDBusGetSessionBus(void);
int virDBusCallMethod(DBusConnection *conn,