[1.2.X] Fixed #11193 -- WSGI handler not properly handling lock on error in load_middleware. Thanks to Phillip Sitbon.

Backport of [15205] from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Andrew Godwin 2011-01-14 23:19:50 +00:00
parent 88dfbc50fb
commit eb9ebb1931
1 changed files with 10 additions and 4 deletions

View File

@ -225,10 +225,16 @@ class WSGIHandler(base.BaseHandler):
# settings weren't available.
if self._request_middleware is None:
self.initLock.acquire()
# Check that middleware is still uninitialised.
if self._request_middleware is None:
self.load_middleware()
self.initLock.release()
try:
# Check that middleware is still uninitialised.
if self._request_middleware is None:
self.load_middleware()
except:
# Unload whatever middleware we got
self._request_middleware = None
raise
finally:
self.initLock.release()
set_script_prefix(base.get_script_name(environ))
signals.request_started.send(sender=self.__class__)