From e4b4fdb710fb0792d58a2b82c066a274e3a67863 Mon Sep 17 00:00:00 2001 From: Thiago Borges Abdnur Date: Sat, 1 Aug 2009 15:45:06 -0300 Subject: [PATCH] Fixing TargetID handle search It seems that there was a semantic error regarding TargetID. This patch changes _alter_properties() to search for TargetID in each handle, that would be the value returned by get_name(), which is different from handle's id. The mistake was considering TargetID == handle.get_id() in this function. Another change was in EnsureChannel(). It was testing if the channel existed before fixing the request. There was a bug in _check_basic_properties(): line 436 was enforcing the existance of a key that is allowed to be missing. Signed-off-by: Thiago Borges Abdnur --- src/server/conn.py | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/server/conn.py b/src/server/conn.py index e196764..b300d66 100644 --- a/src/server/conn.py +++ b/src/server/conn.py @@ -433,7 +433,7 @@ class ConnectionInterfaceRequests( type = props[CHANNEL_INTERFACE + '.ChannelType'] handle_type = props.get(CHANNEL_INTERFACE + '.TargetHandleType', HANDLE_TYPE_NONE) - handle = props[CHANNEL_INTERFACE + '.TargetHandle'] + handle = props.get(CHANNEL_INTERFACE + '.TargetHandle', 0) return (type, handle_type, handle) @@ -476,8 +476,12 @@ class ConnectionInterfaceRequests( if target_handle_type != HANDLE_TYPE_NONE: if target_handle == None: # Turn TargetID into TargetHandle. - self.check_handle(target_handle_type, target_id) - target_handle = self._handles[target_handle_type, target_id] + for handle in self._handles.itervalues(): + if handle.get_name() == target_id and handle.get_type() == target_handle_type: + target_handle = handle.get_id() + if not target_handle: + raise InvalidHandle('TargetID %s not valid for type %d' % + target_id, target_handle_type) altered_properties[CHANNEL_INTERFACE + '.TargetHandle'] = \ target_handle @@ -522,12 +526,12 @@ class ConnectionInterfaceRequests( in_signature='a{sv}', out_signature='boa{sv}', async_callbacks=('_success', '_error')) def EnsureChannel(self, request, _success, _error): - yours = not self._channel_manager.channel_exists(request) - type, handle_type, handle = self._check_basic_properties(request) self._validate_handle(request) props = self._alter_properties(request) + yours = not self._channel_manager.channel_exists(props) + channel = self._channel_manager.channel_for_props(props, signal=False) _success(yours, channel._object_path, props) -- 1.6.0.4