Title: SSL socket is not closed properly
Type: resource usage Stage: test needed
Components: Library (Lib) Versions: Python 2.7, Python 2.6
Status: closed Resolution: duplicate
Dependencies: Superseder: ssl makefile never closes socket
View: 5238
Assigned To: janssen Nosy List: Péter.Szabó, ajaksu2, janssen, pitrou
Priority: normal Keywords:

Created on 2010-02-14 11:24 by Péter.Szabó, last changed 2010-04-20 20:45 by pitrou. This issue is now closed.

Messages (3)
msg99339 - (view) Author: Péter Szabó (Péter.Szabó) Date: 2010-02-14 11:24
Here is how to reproduce:

import socket
import ssl
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sslsock = ssl.SSLSocket(sock)
assert sslsock._sslobj is None
sslsock.connect(('', 443))
assert isinstance(sslsock._sslobj, socket._ssl.SSLType)
assert 0 == sslsock._makefile_refs
assert 1 == sslsock._makefile_refs  # Should be 0.
assert sslsock._sslobj is not None  # Should be None.

I think the problem is in SSLSocket.makefile, which initializes the _fileobject with close=False by default.
msg102675 - (view) Author: Daniel Diniz (ajaksu2) (Python triager) Date: 2010-04-09 03:45
Confirmed on trunk.
msg103750 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-04-20 20:45
Probably a duplicate of issue5238.
Date User Action Args
2010-04-20 20:45:55pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg103750

superseder: ssl makefile never closes socket
resolution: duplicate
2010-04-09 20:07:26pitrousetassignee: janssen

nosy: + janssen
2010-04-09 03:45:11ajaksu2setpriority: normal
versions: + Python 2.7
nosy: + ajaksu2

messages: + msg102675

stage: test needed
2010-02-14 11:24:25Péter.Szabócreate