aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranssih <anssih@svn>2010-08-28 08:40:18 +0000
committeranssih <anssih@svn>2010-08-28 08:40:18 +0000
commit74be9f3f9484ccb97f4d2c1b33eb70f95f9dcbdb (patch)
treeb3fa10d58ab18bf7f116670b7a6715181a379510
parentc238b879370f356a8f29e169a757949b8b3ea8c0 (diff)
fixed: missing device and power notifications on linux
CConsoleUPowerSyscall, CDeviceKitDisksProvider and CUDisksProvider use the unrecommended dbus_connection_pop_message() function that removes a message from the message queue. Doing so, CConsoleUPowerSyscall may remove an unhandled device notification or vice versa. Make those three classes use a private connection to system bus for now so that they can freely mess with the message queue. (cherry picked from commit b8991d3b1e9d5f14fc500fc5a617496a3fb6fe1e) git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@33269 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r--xbmc/linux/ConsoleUPowerSyscall.cpp7
-rw-r--r--xbmc/linux/DeviceKitDisksProvider.cpp7
-rw-r--r--xbmc/linux/UDisksProvider.cpp7
3 files changed, 18 insertions, 3 deletions
diff --git a/xbmc/linux/ConsoleUPowerSyscall.cpp b/xbmc/linux/ConsoleUPowerSyscall.cpp
index 6449775360..492f69823b 100644
--- a/xbmc/linux/ConsoleUPowerSyscall.cpp
+++ b/xbmc/linux/ConsoleUPowerSyscall.cpp
@@ -34,13 +34,17 @@ CConsoleUPowerSyscall::CConsoleUPowerSyscall()
m_lowBattery = false;
dbus_error_init (&m_error);
- m_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &m_error);
+ // TODO: do not use dbus_connection_pop_message() that requires the use of a
+ // private connection
+ m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error);
+ dbus_connection_set_exit_on_disconnect(m_connection, false);
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", &m_error);
dbus_connection_flush(m_connection);
if (dbus_error_is_set(&m_error))
{
CLog::Log(LOGERROR, "UPower: Failed to attach to signal %s", m_error.message);
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}
@@ -55,6 +59,7 @@ CConsoleUPowerSyscall::~CConsoleUPowerSyscall()
{
if (m_connection)
{
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}
diff --git a/xbmc/linux/DeviceKitDisksProvider.cpp b/xbmc/linux/DeviceKitDisksProvider.cpp
index 39c1ff4c10..2cb375b799 100644
--- a/xbmc/linux/DeviceKitDisksProvider.cpp
+++ b/xbmc/linux/DeviceKitDisksProvider.cpp
@@ -177,13 +177,17 @@ CStdString CDeviceKitDiskDevice::toString()
CDeviceKitDisksProvider::CDeviceKitDisksProvider()
{
dbus_error_init (&m_error);
- m_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &m_error);
+ // TODO: do not use dbus_connection_pop_message() that requires the use of a
+ // private connection
+ m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error);
+ dbus_connection_set_exit_on_disconnect(m_connection, false);
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.DeviceKit.Disks'", &m_error);
dbus_connection_flush(m_connection);
if (dbus_error_is_set(&m_error))
{
CLog::Log(LOGERROR, "DeviceKit.Disks: Failed to attach to signal %s", m_error.message);
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}
@@ -200,6 +204,7 @@ CDeviceKitDisksProvider::~CDeviceKitDisksProvider()
if (m_connection)
{
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}
diff --git a/xbmc/linux/UDisksProvider.cpp b/xbmc/linux/UDisksProvider.cpp
index beafede2f2..70bb03b485 100644
--- a/xbmc/linux/UDisksProvider.cpp
+++ b/xbmc/linux/UDisksProvider.cpp
@@ -159,13 +159,17 @@ CStdString CUDiskDevice::toString()
CUDisksProvider::CUDisksProvider()
{
dbus_error_init (&m_error);
- m_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &m_error);
+ // TODO: do not use dbus_connection_pop_message() that requires the use of a
+ // private connection
+ m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error);
+ dbus_connection_set_exit_on_disconnect(m_connection, false);
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UDisks'", &m_error);
dbus_connection_flush(m_connection);
if (dbus_error_is_set(&m_error))
{
CLog::Log(LOGERROR, "UDisks: Failed to attach to signal %s", m_error.message);
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}
@@ -182,6 +186,7 @@ CUDisksProvider::~CUDisksProvider()
if (m_connection)
{
+ dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}