From f2373121d03b7297ac920c5b22e4e90bb4d1f566 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 26 Dec 2010 14:36:51 +0000 Subject: [PATCH] noticed little DoS behavior and lots of connections in netstat (best way to deal with zombie connections is to explicitly close them if not needed any more) --- lib/request/connect.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/request/connect.py b/lib/request/connect.py index 7d83fce0d..fb25e525a 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -231,6 +231,14 @@ class Connect: responseHeaders = conn.info() page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type")) + # Explicit closing of connection object + if not conf.keepAlive: + try: + conn.close() + except Exception, msg: + warnMsg = "problem occured during connection closing ('%s')" % msg + logger.warn(warnMsg) + except urllib2.HTTPError, e: code = e.code status = e.msg