This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: TCP Sockets not closed by TCPServer and StreamRequestHandler
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution:
Dependencies: Superseder: Cumulative patcc:h to http and xmlrpc
View: 6267
Assigned To: Nosy List: kristjan.jonsson
Priority: normal Keywords: needs review, patch

Created on 2009-06-09 16:55 by kristjan.jonsson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
socketserver.patch kristjan.jonsson, 2009-06-09 16:55
Messages (1)
msg89152 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-06-09 16:55
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.
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50497
2009-06-28 21:14:13kristjan.jonssonsetstatus: open -> closed
keywords: patch, patch, needs review
superseder: Cumulative patcc:h to http and xmlrpc
2009-06-09 16:55:37kristjan.jonssoncreate