X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=python%2Fserve-ssi;h=abdb7017aa9fa6bdab68c3d9c107f17ffab7293b;hb=9e70ef793ddcf51edc0f6489eb6f70762380afc0;hp=bbf7188cd17ea538fd5b84602a51a6dea6058321;hpb=6d94a5f6850e75a9d96e9a54845fea5ffe3ed024;p=ashd.git diff --git a/python/serve-ssi b/python/serve-ssi index bbf7188..abdb701 100755 --- a/python/serve-ssi +++ b/python/serve-ssi @@ -151,16 +151,22 @@ if rest != "": sys.exit(0) try: - f = ssifile(open(path), url, path) -except Exception: - simpleerror(sys.stdout, 500, "Server Error", "The server could not access its data.") + try: + f = ssifile(open(path), url, path) + except Exception: + simpleerror(sys.stdout, 500, "Server Error", "The server could not access its data.") + sys.exit(1) + try: + sys.stdout.write("HTTP/1.1 200 OK\n") + sys.stdout.write("Content-Type: text/html\n") + sys.stdout.write("\n") + f.initvars(ssivars) + f.process() + finally: + f.close() +except IOError: + # This is for catching EPIPE, when the client has closed the + # connection. This shouldn't *really* be necessary since the + # process should terminate with SIGPIPE, but apparently Python + # ignores that. sys.exit(1) -try: - sys.stdout.write("HTTP/1.1 200 OK\n") - sys.stdout.write("Content-Type: text/html\n") - sys.stdout.write("\n") - f.initvars(ssivars) - f.process() -finally: - f.close() -