Code

Fix bug with SSL-connection and XMLRPC, see my monologue at
authorschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 8 Oct 2009 12:18:47 +0000 (12:18 +0000)
committerschlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 8 Oct 2009 12:18:47 +0000 (12:18 +0000)
http://thread.gmane.org/gmane.comp.bug-tracking.roundup.user/9700
This also fixes a race condition where the forked roundup process would
consume 99% CPU resources after the client opens the SSL connection but
doesn't send anything, e.g.,
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.connect(('localhost', 443))
 ssl_sock = socket.ssl(s)

git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4362 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/scripts/roundup_server.py

index 2eaa5ece03c7ebe328e9e8a36ca349588d18970f..9427c8fc72383c9c752497e772d24d7c3f6d56be 100644 (file)
@@ -29,6 +29,8 @@ try:
 except ImportError:
     SSL = None
 
+from time import sleep
+
 # python version check
 from roundup import configuration, version_check
 from roundup import __version__ as roundup_version
@@ -127,9 +129,18 @@ class SecureHTTPServer(BaseHTTPServer.HTTPServer):
                         try:
                             line = self.__fileobj.readline(*args)
                         except SSL.WantReadError:
+                            sleep (.1)
                             line = None
                     return line
 
+                def read(self, *args):
+                    """ SSL.Connection can return WantRead """
+                    while True:
+                        try:
+                            return self.__fileobj.read(*args)
+                        except SSL.WantReadError:
+                            sleep (.1)
+
                 def __getattr__(self, attrib):
                     return getattr(self.__fileobj, attrib)