diff options
author | Guido van Rossum <guido@python.org> | 2001-07-10 11:50:09 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-07-10 11:50:09 +0000 |
commit | f65ebee31e6c70c2bd35914780b50d1718b78b1a (patch) | |
tree | 2a5d84ea171de3f582c87981293c9aaac765719c /Lib/SocketServer.py | |
parent | ccf3228424c802adef908651063e0bf66aaeb628 (diff) | |
download | cpython-f65ebee31e6c70c2bd35914780b50d1718b78b1a.tar.gz |
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).
Diffstat (limited to 'Lib/SocketServer.py')
-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 e5863b5adb..e52dddc3b2 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): |