Message87596
I think there are two bugs spotted here. The first is the mentioned
missing "close" param to _fileobject in makefile() method.
The second one was noticed by Jonathan. He doesn't use makefile() at
all, yet his socket isn't closed either. Here's what I think is going on:
The raw filesystem socket seems to be closed only upon garbage
collection, when reference count of socket._realsocket drops to zero
(ie. it's not closed explicitly anywhere). _realsocket is wrapped by
socket._socketobject and all its close() method does is dropping
reference to _realsocket object it wraps.
The bug goes like this:
1. plain = socket.create_connection(...)
it creates and wraps a native _realsocket (plain._sock) with
reference count = 1; "plain" is an instance of _socketobject
2. secure = ssl.wrap_socket(plain)
because SSLSocket inherits from _socketobject, it also wraps
_realsocket plain._sock and the reference count is 2 now
3. secure.close()
it calls in turn it's parent method close() which simply drops raw
_realsocket reference count to 1
4. native socket is still referenced by plain._sock and filesystem
descriptor isn't closed unless plain.close() is called too and refcount
drops to zero
I attach the simplest possible test to prove the bug. |
|
Date |
User |
Action |
Args |
2009-05-11 23:45:10 | marcin.bachry | set | recipients:
+ marcin.bachry, janssen, pitrou, dugan, csapuntz, JonathansCorner.com |
2009-05-11 23:45:10 | marcin.bachry | set | messageid: <1242085510.52.0.206803652492.issue5238@psf.upfronthosting.co.za> |
2009-05-11 23:45:09 | marcin.bachry | link | issue5238 messages |
2009-05-11 23:45:08 | marcin.bachry | create | |
|