Mercurial > p > roundup > code
diff roundup/scripts/roundup_server.py @ 4273:0a684518d609
More SSL fixes.
SSL wants the underlying socket non-blocking. So we don't call
socket.setdefaulttimeout in case of SSL. This apparently now never
raises a WantReadError from SSL. This also fixes a case where a
WantReadError is raised and apparently the bytes already read are
dropped (seems the WantReadError is really an error, not just an
indication to retry).
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Tue, 13 Oct 2009 09:05:21 +0000 |
| parents | 6432c9bfd385 |
| children | 0c024cf74252 |
line wrap: on
line diff
--- a/roundup/scripts/roundup_server.py Tue Oct 13 07:07:19 2009 +0000 +++ b/roundup/scripts/roundup_server.py Tue Oct 13 09:05:21 2009 +0000 @@ -124,14 +124,11 @@ def readline(self, *args): """ SSL.Connection can return WantRead """ - line = None - while not line: + while True: try: - line = self.__fileobj.readline(*args) + return self.__fileobj.readline(*args) except SSL.WantReadError: sleep (.1) - line = None - return line def read(self, *args): """ SSL.Connection can return WantRead """ @@ -596,6 +593,11 @@ if self["SSL"]: base_server = SecureHTTPServer else: + # time out after a minute if we can + # This sets the socket to non-blocking. SSL needs a blocking + # socket, so we do this only for non-SSL connections. + if hasattr(socket, 'setdefaulttimeout'): + socket.setdefaulttimeout(60) base_server = BaseHTTPServer.HTTPServer # obtain request server class @@ -817,10 +819,6 @@ def run(port=undefined, success_message=None): ''' Script entry point - handle args and figure out what to to. ''' - # time out after a minute if we can - if hasattr(socket, 'setdefaulttimeout'): - socket.setdefaulttimeout(60) - config = ServerConfig() # additional options short_options = "hvS"
