summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-10-20 12:19:55 +1030
committerPeter Hutterer <peter.hutterer@redhat.com>2008-10-29 11:55:44 +1030
commit6c451859552e1fc78f6589617482f9ff96d7ed8a (patch)
treedc26a794ff39e9412559e4d13fbcfd2d29e585ff /config
parent102c4dac7c521941f52652152b1660cd7f559d56 (diff)
config: don't add duplicate devices through HAL.
If HAL is restarted, the device list is sent to the server again, leading first to duplicate devices (and thus duplicate events), and later to a FatalError "Too many input devices." dev->config_info contains the UDI for the device. If the UDI of a new devices is equal to one we already have in the device list, just ignore it. Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Diffstat (limited to 'config')
-rw-r--r--config/hal.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/config/hal.c b/config/hal.c
index 6573efed3..c29a573fc 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -166,6 +166,26 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
return ret;
}
+static BOOL
+device_is_duplicate(char *config_info)
+{
+ DeviceIntPtr dev;
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->config_info && (strcmp(dev->config_info, config_info) == 0))
+ return TRUE;
+ }
+
+ for (dev = inputInfo.off_devices; dev; dev = dev->next)
+ {
+ if (dev->config_info && (strcmp(dev->config_info, config_info) == 0))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
device_added(LibHalContext *hal_ctx, const char *udi)
{
@@ -228,6 +248,13 @@ device_added(LibHalContext *hal_ctx, const char *udi)
}
sprintf(config_info, "hal:%s", udi);
+ /* Check for duplicate devices */
+ if (device_is_duplicate(config_info))
+ {
+ LogMessage(X_WARNING, "config/hal: device %s already added. Ignoring.\n", name);
+ goto unwind;
+ }
+
/* ok, grab options from hal.. iterate through all properties
* and lets see if any of them are options that we can add */
set = libhal_device_get_all_properties(hal_ctx, udi, &error);