summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorLeonel Gonzalez <lgonzalez@us.ibm.com>2017-06-08 15:10:03 -0500
committerLeonel Gonzalez <lgonzalez@us.ibm.com>2017-06-09 16:10:59 -0500
commit0b62edfb4555bd78d17f6b7b13fe36ee8c443998 (patch)
treec140bdc5a47b03e3cad54de7e91a431d5e09fb3b /module
parent0bdef95d3fe34e0ca6ce47beca8bfd7635dff77b (diff)
downloadphosphor-rest-server-0b62edfb4555bd78d17f6b7b13fe36ee8c443998.tar.gz
phosphor-rest-server-0b62edfb4555bd78d17f6b7b13fe36ee8c443998.zip
Close file descriptor to release memory
Resolves openbmc/openbmc#1718 Change-Id: Ie3020e38682cd0195202f6b3eedbb0f4907fa666 Signed-off-by: Leonel Gonzalez <lgonzalez@us.ibm.com>
Diffstat (limited to 'module')
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index 605956c..5cb1a56 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -646,8 +646,15 @@ class ImageUploadUtils:
else:
filename = os.path.join(cls.file_loc, filename)
- with open(filename, "w") as fd:
- fd.write(request.body.read())
+ try:
+ file_contents = request.body.read()
+ request.body.close()
+ with open(filename, "w") as fd:
+ fd.write(file_contents)
+ except (IOError, ValueError), e:
+ abort(400, str(e))
+ except:
+ abort(400, "Unexpected Error")
class ImagePostHandler(RouteHandler):
OpenPOWER on IntegriCloud