Skip to content

Commit f56f145

Browse files
author
Ralf Schlatterbeck
committed
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).
1 parent d5c2985 commit f56f145

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

CHANGES.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2009-XX-XX 1.4.XX (rXXXX)
5+
6+
Fixes:
7+
- More SSL fixes. SSL wants the underlying socket non-blocking. So we
8+
don't call socket.setdefaulttimeout in case of SSL. This apparently
9+
never raises a WantReadError from SSL.
10+
This also fixes a case where a WantReadError is raised and apparently
11+
the bytes already read are dropped (seems the WantReadError is really
12+
an error, not just an indication to retry).
13+
414
2009-10-09 1.4.10 (r4374)
515

616
Fixes:

roundup/scripts/roundup_server.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,11 @@ def __init__(self, fileobj):
124124

125125
def readline(self, *args):
126126
""" SSL.Connection can return WantRead """
127-
line = None
128-
while not line:
127+
while True:
129128
try:
130-
line = self.__fileobj.readline(*args)
129+
return self.__fileobj.readline(*args)
131130
except SSL.WantReadError:
132131
sleep (.1)
133-
line = None
134-
return line
135132

136133
def read(self, *args):
137134
""" SSL.Connection can return WantRead """
@@ -596,6 +593,11 @@ class RequestHandler(RoundupRequestHandler):
596593
if self["SSL"]:
597594
base_server = SecureHTTPServer
598595
else:
596+
# time out after a minute if we can
597+
# This sets the socket to non-blocking. SSL needs a blocking
598+
# socket, so we do this only for non-SSL connections.
599+
if hasattr(socket, 'setdefaulttimeout'):
600+
socket.setdefaulttimeout(60)
599601
base_server = BaseHTTPServer.HTTPServer
600602

601603
# obtain request server class
@@ -817,10 +819,6 @@ def daemonize(pidfile):
817819
def run(port=undefined, success_message=None):
818820
''' Script entry point - handle args and figure out what to to.
819821
'''
820-
# time out after a minute if we can
821-
if hasattr(socket, 'setdefaulttimeout'):
822-
socket.setdefaulttimeout(60)
823-
824822
config = ServerConfig()
825823
# additional options
826824
short_options = "hvS"

0 commit comments

Comments
 (0)