[issue6248] TCP Sockets not closed by TCPServer and StreamRequestHandler

Kristján Valur Jónsson report at bugs.python.org
Tue Jun 9 18:55:38 CEST 2009


New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:

When an error occurs in a StreamRequestHandler, its wfile and rfile 
members are not closed.  This causes the underlaying socket to stay 
alive and and it is therefore not closed, even when the SocketServer 
closes it in server.close_request().  This means that a client will not 
know that there is no one listening on the other end.

This is due to incorrect error handling semantics in BaseRequestHandler.

This patch fixes the error handling in BaseRequestHandler, ensuring that 
request.finish() is called when request.setup() has completed.

I also add an explicit socket.shutdown() in TCPServer.close_request() to 
make sure that at least a half-close occurs even in the face of socket 
reference leaks.

----------
components: Library (Lib)
files: socketserver.patch
keywords: needs review, patch, patch
messages: 89152
nosy: krisvale
severity: normal
status: open
title: TCP Sockets not closed by TCPServer and StreamRequestHandler
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file14245/socketserver.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6248>
_______________________________________


More information about the Python-bugs-list mailing list