summaryrefslogtreecommitdiff
path: root/Xi/xiproperty.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-10-08 14:12:21 +1030
committerPeter Hutterer <peter.hutterer@redhat.com>2008-10-13 13:50:40 +1030
commitf3f6ea89aa9e0ffe9e37bc059e5e6bf75be4ee9f (patch)
tree6d466cd9fe3b932d709b15886dea119f79ead410 /Xi/xiproperty.c
parentad67e3f063aa79247270f29e989bbfe5f62c9ed7 (diff)
Xi: check all handlers before applying property changes.
The current code exposes to inconsistent updates, i.e. if handler N succeeds but handler N+1 fails in setting the property, an error is returned to the client although parts of the server now behave as if the property change succeeded. This patch adds a "checkonly" parameter to the SetProperty handler. The handlers are then called twice, once with checkonly set to TRUE. On the checkonly run, handlers _MUST_ return error codes if the property cannot be applied. Handlers are not permitted to actually apply the changes. On the second run, handlers are permitted to apply property changes. Errors codes returned on the second run are ignored.
Diffstat (limited to 'Xi/xiproperty.c')
-rw-r--r--Xi/xiproperty.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 1e4ed466b..2ff5cae9f 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -97,7 +97,8 @@ long
XIRegisterPropertyHandler(DeviceIntPtr dev,
int (*SetProperty) (DeviceIntPtr dev,
Atom property,
- XIPropertyValuePtr prop),
+ XIPropertyValuePtr prop,
+ BOOL checkonly),
int (*GetProperty) (DeviceIntPtr dev,
Atom property),
int (*DeleteProperty) (DeviceIntPtr dev,
@@ -346,22 +347,31 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
if (dev->properties.handlers)
{
- XIPropertyHandlerPtr handler = dev->properties.handlers;
- while(handler)
+ XIPropertyHandlerPtr handler;
+ BOOL checkonly = TRUE;
+ /* run through all handlers with checkonly TRUE, then again with
+ * checkonly FALSE. Handlers MUST return error codes on the
+ * checkonly run, errors on the second run are ignored */
+ do
{
- if (handler->SetProperty)
+ handler = dev->properties.handlers;
+ while(handler)
{
- rc = handler->SetProperty(dev, prop->propertyName,
- &new_value);
- if (rc != Success)
+ if (handler->SetProperty)
{
- if (new_value.data)
- xfree (new_value.data);
- return (rc);
+ rc = handler->SetProperty(dev, prop->propertyName,
+ &new_value, checkonly);
+ if (checkonly && rc != Success)
+ {
+ if (new_value.data)
+ xfree (new_value.data);
+ return (rc);
+ }
}
+ handler = handler->next;
}
- handler = handler->next;
- }
+ checkonly = !checkonly;
+ } while (!checkonly);
}
if (prop_value->data)
xfree (prop_value->data);