From: Simo Sorce Date: Thu, 1 May 2014 20:37:12 +0000 (-0400) Subject: Eliminte stale locks X-Git-Tag: v0.2.2~7 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=commitdiff_plain;h=8cd7481f96f5f67efb69323024e56d57df992eb5 Eliminte stale locks If the server crashes stale lock files may e left behind. This will cause the application to deadlock for the user that has the misfortune of having a stale lock. Forcibly remove all locks on startup. Signed-off-by: Simo Sorce --- diff --git a/ipsilon/ipsilon b/ipsilon/ipsilon index 9fa370e..fec19e4 100755 --- a/ipsilon/ipsilon +++ b/ipsilon/ipsilon @@ -19,7 +19,7 @@ import sys sys.stdout = sys.stderr - +import glob import os import atexit import cherrypy @@ -28,6 +28,19 @@ from ipsilon.util import page from ipsilon.root import Root from jinja2 import Environment, FileSystemLoader + +def nuke_session_locks(): + if cherrypy.config['tools.sessions.on']: + try: + sessdir = cherrypy.config['tools.sessions.storage_path'] + for l in glob.glob(os.path.join(sessdir, '*.lock')): + try: + os.remove(l) + except Exception: # pylint: disable=broad-except + pass + except Exception: # pylint: disable=broad-except + pass + cfgfile = None if (len(sys.argv) > 1): cfgfile = sys.argv[-1] @@ -40,6 +53,8 @@ else: cherrypy.config.update(cfgfile) +nuke_session_locks() + datastore = Store() admin_config = datastore.get_admin_config() for option in admin_config: