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 ...@@ -23,7 +23,7 @@ refresh_interval = 5 # interval of html refresh
usage_limit = 1 # maximum concurrently processed requests usage_limit = 1 # maximum concurrently processed requests
# Settings defaults # Settings defaults
always_start_thread = True always_start_thread = True # True is highly recommended
debug = False debug = False
rescan_on_display = False rescan_on_display = False
persistent_storage_file = '/tmp/ulg.data' persistent_storage_file = '/tmp/ulg.data'
......
...@@ -350,11 +350,6 @@ class ULGCgi: ...@@ -350,11 +350,6 @@ class ULGCgi:
def write(self,string): def write(self,string):
self.session.appendResult(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 # define trivial thread function
def commandThreadBody(session,decreaseUsageMethod): def commandThreadBody(session,decreaseUsageMethod):
ulgmodel.debug("Running command: "+session.getCommand().getName()) ulgmodel.debug("Running command: "+session.getCommand().getName())
...@@ -368,6 +363,10 @@ class ULGCgi: ...@@ -368,6 +363,10 @@ class ULGCgi:
session.setFinished() session.setFinished()
decreaseUsageMethod() 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) # fork a daemon process (fork two times to decouple with parent)
sys.stdout.flush() sys.stdout.flush()
child_pid = os.fork() child_pid = os.fork()
...@@ -384,9 +383,8 @@ class ULGCgi: ...@@ -384,9 +383,8 @@ class ULGCgi:
sys.exit(0) sys.exit(0)
else: else:
# directly run the selected action # directly run the selected action, DEPRECATED
commandThreadBody(session,self.decreaseUsage) commandThreadBody(session,self.decreaseUsage)
else: else:
# stop and report no-op # stop and report no-op
self.stopSessionOverlimit(session) 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