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

I found this defect at PyCon 2011 after spending a lot of type fidgeting with 
ssl.  The test_ssl.py unittest was using timeout on accept sockets and it was 
working fine there, but not with the code I was working out.  Turns out that 
_ssl.py resets the timeout state of sockets, but not regular sockets.

In short:  If you have a socket with settimeout(1), then accept a connection on 
it, the new socket will have gettimeout()==None, but its state will still 
(internally) be non-blocking.  The attached script demonstrates the issue.

This is an issue with all versions of python from 2.5 upwards.

There are basically two things we can do to fis this:
1) retain gettimeout()=None but internally make sure we set the resulting 
socket to blocking mode
2) have the accepted socket inherit the timeout properties of the parent socket 
properly, and so inherit its timeout value too.

Number 2 is more in line with expected BSD socket behaviour that sockets at 
least inherit the non-blocking attribute of their parent socket.

----------
components: IO
files: bug.py
messages: 132581
nosy: krisvale
priority: normal
severity: normal
status: open
title: socket.accept() with a timout socket creates bogus socket
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 
3.3, Python 3.4
Added file: http://bugs.python.org/file21473/bug.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11721>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to