From 8cd7481f96f5f67efb69323024e56d57df992eb5 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 1 May 2014 16:37:12 -0400 Subject: [PATCH] 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 --- ipsilon/ipsilon | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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: -- 2.20.1