From bc0c67380072ad3461cd9a0dfdb71dc37f54918d Mon Sep 17 00:00:00 2001 From: Marri Devender Rao Date: Mon, 20 Nov 2017 00:15:47 -0600 Subject: Fix infinite do_put recursive call with retry only once For failure in do-put method call REST server computes the argument types based on the signature and makes a recursive call with the modified argument types. Without proper exit clause recursive call is falling into an infinite loop, modified to retry only once. Also fixed do_post which has similar retry logic. Fixes openbmc/openbmc#2653 Change-Id: I150464de5585ebdfab4ae2da2083a62bd63caca1 Signed-off-by: Marri Devender Rao --- module/obmc/wsgi/apps/rest_dbus.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/obmc/wsgi/apps') diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index e0c2edf..b47ea4e 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -343,7 +343,7 @@ class MethodHandler(RouteHandler): def setup(self, path, method): request.route_data['map'] = self.find(path, method) - def do_post(self, path, method): + def do_post(self, path, method, retry=True): try: args = [] if request.parameter_list: @@ -371,7 +371,7 @@ class MethodHandler(RouteHandler): except dbus.exceptions.DBusException, e: paramlist = [] - if e.get_dbus_name() == DBUS_INVALID_ARGS: + if e.get_dbus_name() == DBUS_INVALID_ARGS and retry == True: signature_list = get_method_signature(self.bus, self.service, path, self.interface, @@ -387,7 +387,7 @@ class MethodHandler(RouteHandler): converted_value = convert_type(expected_type, value) paramlist.append(converted_value) request.parameter_list = paramlist - self.do_post(path, method) + self.do_post(path, method, False) return except Exception as ex: abort(400, "Failed to convert the types") @@ -454,7 +454,7 @@ class PropertyHandler(RouteHandler): name = request.route_data['name'] return request.route_data['obj'][path][name] - def do_put(self, path, prop, value=None): + def do_put(self, path, prop, value=None, retry=True): if value is None: value = request.parameter_list @@ -465,7 +465,7 @@ class PropertyHandler(RouteHandler): except ValueError, e: abort(400, str(e)) except dbus.exceptions.DBusException, e: - if e.get_dbus_name() == DBUS_INVALID_ARGS: + if e.get_dbus_name() == DBUS_INVALID_ARGS and retry == True: bus_name = properties_iface.bus_name expected_type = get_type_signature_by_introspection(self.bus, bus_name, @@ -476,7 +476,7 @@ class PropertyHandler(RouteHandler): converted_value = None try: converted_value = convert_type(expected_type, value) - self.do_put(path, prop, converted_value) + self.do_put(path, prop, converted_value, False) return except Exception as ex: abort(403, "Failed to convert %s to type %s" % -- cgit v1.2.1