From b5003220b9a8e87c598873b5e3f02e7511d913de Mon Sep 17 00:00:00 2001 From: frisco <> Date: Fri, 21 Jan 2011 05:48:12 +0000 Subject: [PATCH] Fixed intermittent cryptonas-server crash at startup --- .../chroot_local-hooks/50cnas-cherrypy-fix.sh | 23 ++++++++++++ .../cryptonas-live/_cpwsgiserver.py.diff | 36 +++++++++---------- 2 files changed, 39 insertions(+), 20 deletions(-) create mode 100755 config/chroot_local-hooks/50cnas-cherrypy-fix.sh diff --git a/config/chroot_local-hooks/50cnas-cherrypy-fix.sh b/config/chroot_local-hooks/50cnas-cherrypy-fix.sh new file mode 100755 index 0000000..1731287 --- /dev/null +++ b/config/chroot_local-hooks/50cnas-cherrypy-fix.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# +# License: This script is distributed under the terms of version 2 +# of the GNU GPL. See the LICENSE file included with the package. +# +# $Id: $ +# +# this script is part of the build process of CryptoNAS +# +# 2010-01-20 James Crofts adapted to implement a different CherryPy workaround +# 2008-11-27 James Crofts backported workaround from CherryPy src repository. +# See http://www.cherrypy.org/ticket/686 and +# http://devel.cryptobox.org/ticket/216. +# + +## Stop the build process if any of the following steps fail +set -e + +##Hack to prevent intermittent cherrypy crashes at startup +DIFF="/usr/share/cryptonas-live/_cpwsgiserver.py.diff" +##These two files are identical before the patch and must be identical +##afterward as well: +patch /usr/share/python-support/python-cherrypy/cherrypy/_cpwsgiserver.py < ${DIFF} diff --git a/config/chroot_local-includes/usr/share/cryptonas-live/_cpwsgiserver.py.diff b/config/chroot_local-includes/usr/share/cryptonas-live/_cpwsgiserver.py.diff index 78d79c4..25f8695 100644 --- a/config/chroot_local-includes/usr/share/cryptonas-live/_cpwsgiserver.py.diff +++ b/config/chroot_local-includes/usr/share/cryptonas-live/_cpwsgiserver.py.diff @@ -1,20 +1,16 @@ ---- chroot/usr/share/python-support/python-cherrypy/cherrypy/_cpwsgiserver.py 2006-04-24 18:37:45.000000000 -0700 -+++ chroot/usr/share/cryptonas-live/_cpwsgiserver-copy.py 2008-11-27 22:53:49.000000000 -0700 -@@ -200,10 +200,17 @@ - response = request.wsgi_app(request.environ, - request.start_response) - for line in response: - request.write(line) - except socket.error, e: -+ msg = e.args[1] -+ if msg == "Bad file descriptor": -+ # Our socket was closed -+ return -+ if msg == "Resource temporarily unavailable": -+ # Just try again. See http://www.cherrypy.org/ticket/479. -+ return - errno = e.args[0] - if errno not in socket_errors_to_ignore: - traceback.print_exc() - except (KeyboardInterrupt, SystemExit), exc: - self.server.interrupt = exc +--- chroot/usr/share/python-support/python-cherrypy/cherrypy/_cpwsgiserver.py.old 2011-01-20 22:07:45.000000000 -0700 ++++ chroot/usr/share/python-support/python-cherrypy/cherrypy/_cpwsgiserver.py.new 2011-01-04 23:50:26.000000000 -0700 +@@ -409,10 +412,13 @@ + # Our socket was closed + return + if msg == "Resource temporarily unavailable": + # Just try again. See http://www.cherrypy.org/ticket/479. + return ++ if msg == "Interrupted system call": ++ # See http://www.cherrypy.org/ticket/861. ++ return + raise + + def stop(self): + """Gracefully shutdown a server that is serving forever.""" + self.ready = False