Code

More SSL fixes. SSL wants the underlying socket non-blocking. So we
authorschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 13 Oct 2009 09:05:21 +0000 (09:05 +0000)
committerschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Tue, 13 Oct 2009 09:05:21 +0000 (09:05 +0000)
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
roundup/scripts/roundup_server.py

index 27cc746b5334c5d8fc3f2928f027f9761805fb7d..14cba11db3ff6403af2845dab1fa230fb310a44b 100644 (file)
@@ -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.
 
 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:
 2009-10-09 1.4.10 (r4374)
 
 Fixes:
index 9427c8fc72383c9c752497e772d24d7c3f6d56be..2ebd56ea3c79e3bb26f8b3ea0df00d0bd573eb6a 100644 (file)
@@ -124,14 +124,11 @@ class SecureHTTPServer(BaseHTTPServer.HTTPServer):
 
                 def readline(self, *args):
                     """ SSL.Connection can return WantRead """
 
                 def readline(self, *args):
                     """ SSL.Connection can return WantRead """
-                    line = None
-                    while not line:
+                    while True:
                         try:
                         try:
-                            line = self.__fileobj.readline(*args)
+                            return self.__fileobj.readline(*args)
                         except SSL.WantReadError:
                             sleep (.1)
                         except SSL.WantReadError:
                             sleep (.1)
-                            line = None
-                    return line
 
                 def read(self, *args):
                     """ SSL.Connection can return WantRead """
 
                 def read(self, *args):
                     """ SSL.Connection can return WantRead """
@@ -596,6 +593,11 @@ class ServerConfig(configuration.Config):
         if self["SSL"]:
             base_server = SecureHTTPServer
         else:
         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
             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.
     '''
 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"
     config = ServerConfig()
     # additional options
     short_options = "hvS"