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.

classification
Title: socket timeout inheritance on accept
Type: enhancement Stage: test needed
Components: Extension Modules, Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: On Mac / BSD sockets returned by accept inherit the parent's FD flags
View: 7995
Assigned To: Nosy List: kirma, ned.deily, terry.reedy
Priority: normal Keywords:

Created on 2006-07-02 13:05 by kirma, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg60934 - (view) Author: Jari Kirma (kirma) Date: 2006-07-02 13:05
Socket objects returned by socket.accept() get their
blocking and timeout setting(s) from
socket.defaulttimeout. This can be in conflict with
reality of the (non-)blocking mode of actual OS-level
socket they use. For instance, FreeBSD sockets inherit
their socket options from the parent socket on
accept(2) system call, and thus a socket object with
defined socket timeout and default defaulttimeout
returns a socket object that seems to be blocking,
non-timeout socket, but the underlying OS socket is
actually in nonblocking mode, which can cause read/recv
and write/send operations to behave unexpectedly. Even
worse, POSIX/SUSv3 doesn't explicitly require socket
option inheritance
(http://www.opengroup.org/onlinepubs/009695399/functions/accept.html).
  

The socket library should explicitly set the socket
timeout mode (either to defaulttimeout, or with
accompanying documentation, inherit the value from
socket object passed to accept()) and modify the OS
socket options accordingly.
msg60935 - (view) Author: Jari Kirma (kirma) Date: 2006-07-02 13:23
Logged In: YES 
user_id=1548868

Making socket objects behave reliably can be achieved simply
by always calling internal_setblocking in init_sockobject of
socketmodule.c, but this causes overhead of one system call
on all socket creations. Alternatively one could call
internal_setblocking from sock_accept if parent socket has
timeouts/nonblocking mode enabled. This should work in under
all reasonable scenanarios and avoid system call overhead on
majority of cases.
msg113368 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-09 03:40
I am sorry this has not gotten any response. There does not seem to currently be anyone specifically working on the socket module, so this got lost among hundreds of other feature requests.
msg124960 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-12-31 09:32
The problem you have reported here was later independently reported in Issue7995 where a possible fix has been proposed.  Suggest adding yourself to the nosy list of that issue to monitor current status.
History
Date User Action Args
2022-04-11 14:56:18adminsetgithub: 43596
2010-12-31 09:32:01ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg124960

superseder: On Mac / BSD sockets returned by accept inherit the parent's FD flags
resolution: duplicate
2010-08-09 03:40:22terry.reedysetnosy: + terry.reedy

messages: + msg113368
versions: + Python 3.2, - Python 3.1, Python 2.7
2009-03-30 05:57:09ajaksu2setstage: test needed
type: enhancement
components: + Extension Modules
versions: + Python 3.1, Python 2.7, - Python 2.5
2006-07-02 13:05:04kirmacreate