From 81e2fe8306ab79028f5836352228c3eef3aa71e5 Mon Sep 17 00:00:00 2001 From: Arturo 'Buanzo' Busleiman Date: Sun, 30 Aug 2009 13:51:17 +0000 Subject: [PATCH] added 'unexpected communication error' fix to ChangeLog. Added formatExceptionInfo to server/asyncserver.py We should move that function to a helpers module. git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_8@739 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- ChangeLog | 2 ++ server/asyncserver.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6b5c9864..cb4c9b63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ Fail2Ban (version 0.8.4) 2009/02/?? ver. 0.8.4 (2009/??/??) - stable ---------- +- Fixed the 'unexpected communication error' problem by means of + use_poll=False in Python >= 2.6. - Merged patches from Debian package. Thanks to Yaroslav Halchenko. - Use current day and month instead of Jan 1st if both are not available in the log. Thanks to Andreas Itzchak Rehberg. diff --git a/server/asyncserver.py b/server/asyncserver.py index 33e80aff..0714513d 100644 --- a/server/asyncserver.py +++ b/server/asyncserver.py @@ -30,6 +30,19 @@ import asyncore, asynchat, socket, os, logging, sys # Gets the instance of the logger. logSys = logging.getLogger("fail2ban.server") +# we should move this to some sort of helper functions module + +def formatExceptionInfo(): + """ Author: Arturo 'Buanzo' Busleiman """ + import sys + cla, exc = sys.exc_info()[:2] + excName = cla.__name__ + try: + excArgs = exc.__dict__["args"] + except KeyError: + excArgs = str(exc) + return (excName, excArgs) + ## # Request handler class. # @@ -69,7 +82,9 @@ class RequestHandler(asynchat.async_chat): self.close_when_done() def handle_error(self): - logSys.error("Unexpected communication error") + e1,e2 = formatExceptionInfo() + logSys.error("Unexpected communication error: "+e2) + logSys.error(traceback.format_exc().splitlines()) self.close() ##