diff options
author | Guido van Rossum <guido@python.org> | 2001-07-10 11:50:09 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-07-10 11:50:09 (GMT) |
commit | 7de4d645a5e268d202409b35d797b3db09eec476 (patch) | |
tree | 542837756da4d187e361fe483ab1a9b410a7fa4a | |
parent | 06e415fe52796629dd1342bb02103b5a51fbcd9a (diff) | |
download | cpython-7de4d645a5e268d202409b35d797b3db09eec476.zip cpython-7de4d645a5e268d202409b35d797b3db09eec476.tar.gz cpython-7de4d645a5e268d202409b35d797b3db09eec476.tar.bz2 |
IMPORTANT FIX: This should definitely go into the 2.1.1 release!!!
Fix various serious problems:
- The ThreadingTCPServer class and its derived classes were completely
broken because the main thread would close the request before the
handler thread had time to look at it. This was introduced by
Ping's close_request() patch. The fix moves the close_request()
calls to after the handler has run to completion in the BaseServer
class and the ForkingMixIn class; when using the ThreadingMixIn,
closing the request is the handler's responsibility.
- The ForkingUDPServer class has always been been broken because the
socket was closed in the child before calling the handler. I fixed
this by simply not calling server_close() in the child at all.
- I cannot get the UnixDatagramServer class to work at all. The
recvfrom() call doesn't return a meaningful client address. I added
a comment to this effect. Maybe it works on other Unix versions.
- The __all__ variable was missing ThreadingMixIn and ForkingMixIn.
- Bumped __version__ to "0.4".
- Added a note about the test suite (to be checked in shortly).
-rw-r--r-- | Lib/SocketServer.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py index e5863b5..e52dddc 100644 --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -120,7 +120,12 @@ BaseServer: # Author of the BaseServer patch: Luke Kenneth Casson Leighton -__version__ = "0.3" +# XXX Warning! +# There is a test suite for this module, but it cannot be run by the +# standard regression test. +# To run it manually, run Lib/test/test_socketserver.py. + +__version__ = "0.4" import socket @@ -129,7 +134,8 @@ import os __all__ = ["TCPServer","UDPServer","ForkingUDPServer","ForkingTCPServer", "ThreadingUDPServer","ThreadingTCPServer","BaseRequestHandler", - "StreamRequestHandler","DatagramRequestHandler"] + "StreamRequestHandler","DatagramRequestHandler", + "ThreadingMixIn", "ForkingMixIn"] if hasattr(socket, "AF_UNIX"): __all__.extend(["UnixStreamServer","UnixDatagramServer", "ThreadingUnixStreamServer", @@ -215,7 +221,7 @@ class BaseServer: self.process_request(request, client_address) except: self.handle_error(request, client_address) - self.close_request(request) + self.close_request(request) def verify_request(self, request, client_address): """Verify the request. May be overridden. @@ -232,6 +238,7 @@ class BaseServer: """ self.finish_request(request, client_address) + self.close_request(request) def server_close(self): """Called to clean-up the server. @@ -423,18 +430,17 @@ class ForkingMixIn: if self.active_children is None: self.active_children = [] self.active_children.append(pid) + self.close_request(request) return else: # Child process. # This must never return, hence os._exit()! try: - self.server_close() self.finish_request(request, client_address) os._exit(0) except: try: - self.handle_error(request, - client_address) + self.handle_error(request, client_address) finally: os._exit(1) @@ -545,6 +551,9 @@ class StreamRequestHandler(BaseRequestHandler): class DatagramRequestHandler(BaseRequestHandler): + # XXX Regrettably, I cannot get this working on Linux; + # s.recvfrom() doesn't return a meaningful client address. + """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): |