Commit 7626c2b9 authored by Tomas Hlavacek's avatar Tomas Hlavacek

Bugfixes in commandThreadRun code.

Code scope changed - it was wrong and running directly outside
of a new thread would cause Exception.
parent 4aff4383
......@@ -23,7 +23,7 @@ refresh_interval = 5 # interval of html refresh
usage_limit = 1 # maximum concurrently processed requests
# Settings defaults
always_start_thread = True
always_start_thread = True # True is highly recommended
debug = False
rescan_on_display = False
persistent_storage_file = '/tmp/ulg.data'
......
......@@ -350,11 +350,6 @@ class ULGCgi:
def write(self,string):
self.session.appendResult(string)
# try to increase usage counter
if(self.increaseUsage()):
# start new thread if needed
if(defaults.always_start_thread or session.getRouter().getForkNeeded()):
# define trivial thread function
def commandThreadBody(session,decreaseUsageMethod):
ulgmodel.debug("Running command: "+session.getCommand().getName())
......@@ -368,6 +363,10 @@ class ULGCgi:
session.setFinished()
decreaseUsageMethod()
# try to increase usage counter
if(self.increaseUsage()):
# start new thread if needed
if(defaults.always_start_thread or session.getRouter().getForkNeeded()):
# fork a daemon process (fork two times to decouple with parent)
sys.stdout.flush()
child_pid = os.fork()
......@@ -384,9 +383,8 @@ class ULGCgi:
sys.exit(0)
else:
# directly run the selected action
# directly run the selected action, DEPRECATED
commandThreadBody(session,self.decreaseUsage)
else:
# stop and report no-op
self.stopSessionOverlimit(session)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment