fix for WSGI-based PLCAPI, on behalf of Thomas Dreibholz
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 25 Jul 2013 19:07:39 +0000 (21:07 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 25 Jul 2013 19:07:39 +0000 (21:07 +0200)
apache/plc.wsgi

index e6a7eb3..c37d369 100644 (file)
@@ -12,8 +12,6 @@ import traceback
 from PLC.Debug import log
 from PLC.API import PLCAPI
 
-api = PLCAPI()
-
 def application(environ, start_response):
     try:
         status = '200 OK'
@@ -28,6 +26,12 @@ def application(environ, start_response):
 </body></html>
 """
         else:
+            # Thomas Dreibholz <dreibh@simula.no>
+            # Note that this function is called within multiple threads!
+            # "api" MUST be a local variable instead of a global one.
+            # Otherwise, this causes concurrent accesses to the same
+            # object within different threads!
+            api = PLCAPI()
             api.environ = environ
             content_type = 'text/xml'
             ip = environ.get('REMOTE_ADDR')