From 42df7386b4774fa9d6224464cc3a59aade01ac9d Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Tue, 13 Oct 2009 09:05:21 +0000 Subject: [PATCH] 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). git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4377 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 10 ++++++++++ roundup/scripts/roundup_server.py | 16 +++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 27cc746..14cba11 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,16 @@ This file contains the changes to the Roundup system over time. The entries are given with the most recent entry first. +2009-XX-XX 1.4.XX (rXXXX) + +Fixes: +- More SSL fixes. SSL wants the underlying socket non-blocking. So we + don't call socket.setdefaulttimeout in case of SSL. This apparently + 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). + 2009-10-09 1.4.10 (r4374) Fixes: diff --git a/roundup/scripts/roundup_server.py b/roundup/scripts/roundup_server.py index 9427c8f..2ebd56e 100644 --- a/roundup/scripts/roundup_server.py +++ b/roundup/scripts/roundup_server.py @@ -124,14 +124,11 @@ class SecureHTTPServer(BaseHTTPServer.HTTPServer): 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 @@ class ServerConfig(configuration.Config): 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 @@ undefined = [] 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" -- 2.30.2