diff options
author | Helmut Grohne <helmut@subdivi.de> | 2011-01-12 21:28:52 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2011-01-12 21:28:52 +0100 |
commit | 613e0e381a2860c8f027b4665a20a90768875ebd (patch) | |
tree | e1f50edd6026a8cc5bdc03a44096b70d5042b089 /wsgitools/scgi | |
parent | f87a8fb2926643a1c2204ea0a412c3d959854ee0 (diff) | |
download | wsgitools-613e0e381a2860c8f027b4665a20a90768875ebd.tar.gz |
scgi.asynchronous catches more errors now
This addresses a disputed denial of service condition described in
http://bugs.python.org/issue6706. Note that wsgitools is not hit as hard as
pyftplib.
Diffstat (limited to 'wsgitools/scgi')
-rw-r--r-- | wsgitools/scgi/asynchronous.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py index ecc27fb..82dec02 100644 --- a/wsgitools/scgi/asynchronous.py +++ b/wsgitools/scgi/asynchronous.py @@ -9,6 +9,7 @@ try: import cStringIO as io except ImportError: import StringIO as io +import errno class SCGIConnection(asyncore.dispatcher): """SCGI connection class used by L{SCGIServer}.""" @@ -228,10 +229,16 @@ class SCGIServer(asyncore.dispatcher): def handle_accept(self): """asyncore interface""" - ret = self.accept() - if ret is not None: - conn, addr = ret - SCGIConnection(self, conn, addr, **self.conf) + try: + ret = self.accept() + except socket.error, err: + # See http://bugs.python.org/issue6706 + if err.args[0] not in (errno.ECONNABORTED, errno.EAGAIN): + raise + else: + if ret is not None: + conn, addr = ret + SCGIConnection(self, conn, addr, **self.conf) def run(self): """Runs the server. It will not return and you can invoke |