Fixed intermittent cryptonas-server crash at startup

This commit is contained in:
frisco 2011-01-21 05:48:12 +00:00
parent e862e16a59
commit b5003220b9
2 changed files with 39 additions and 20 deletions

View file

@ -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}

View file

@ -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/python-support/python-cherrypy/cherrypy/_cpwsgiserver.py.old 2011-01-20 22:07:45.000000000 -0700
+++ chroot/usr/share/cryptonas-live/_cpwsgiserver-copy.py 2008-11-27 22:53:49.000000000 -0700 +++ chroot/usr/share/python-support/python-cherrypy/cherrypy/_cpwsgiserver.py.new 2011-01-04 23:50:26.000000000 -0700
@@ -200,10 +200,17 @@ @@ -409,10 +412,13 @@
response = request.wsgi_app(request.environ, # Our socket was closed
request.start_response) return
for line in response: if msg == "Resource temporarily unavailable":
request.write(line) # Just try again. See http://www.cherrypy.org/ticket/479.
except socket.error, e: return
+ msg = e.args[1] + if msg == "Interrupted system call":
+ if msg == "Bad file descriptor": + # See http://www.cherrypy.org/ticket/861.
+ # Our socket was closed + return
+ return raise
+ if msg == "Resource temporarily unavailable":
+ # Just try again. See http://www.cherrypy.org/ticket/479. def stop(self):
+ return """Gracefully shutdown a server that is serving forever."""
errno = e.args[0] self.ready = False
if errno not in socket_errors_to_ignore:
traceback.print_exc()
except (KeyboardInterrupt, SystemExit), exc:
self.server.interrupt = exc