[issue10115] Support accept4() for atomic setting of flags at socket creation
STINNER Victor added the comment: Python 3.4 now uses accept4() internally for socket.socket.accept(), the new socket is created non-inheritable. See the PEP 446 for more information (PEP implemented in the issue #18571). -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Changes by STINNER Victor victor.stin...@gmail.com: -- versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
STINNER Victor added the comment: My implementation of the PEP 433 uses accept4() for socket.accept() if the (new) cloexec parameter is True: http://hg.python.org/features/pep-433/file/46b7a077ae87/Modules/socketmodule.c#l1961 The code fallbacks to accept() if accept4() fails with ENOSYS. It happens if the glibc version is 2.10 or newer, whereas the Linux kernel is older than 2.6.28. I didn't test the fallback yet. I see in changeset 12442ac3f7dd (issue #7523) that SOCK_NONBLOCK is also set in the flags parameters of accept4(). I should probably also do that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
STINNER Victor added the comment: See the PEP 433 which proposes an unified API to set/unset close-on-exec flag on any function creating a file descriptor. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Matt Joiner anacro...@gmail.com added the comment: Can we get this exposed as an os.accept4, and an optional flags parameter to socket.socket.accept? -- nosy: +anacrolix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment: up? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Antoine Pitrou pit...@free.fr added the comment: What value should we assign to sock-sock_timeout if SOCK_NONBLOCK was specified in accept4() call? The same value as for other non-blocking sockets, IMO. And in socket.py should we check as in original accept: if getdefaulttimeout() is None and self.gettimeout(): sock.setblocking(True) I don't think so, since the whole point of accept4() is to override normal flags creation. -- versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment: The same value as for other non-blocking sockets, IMO. There are three possible values I think: 1. parent's current sock_timeout 2. global default socket timeout 3. 0 Can you please tell which one? I assume it should be number 3. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Antoine Pitrou pit...@free.fr added the comment: The same value as for other non-blocking sockets, IMO. There are three possible values I think: 1. parent's current sock_timeout 2. global default socket timeout 3. 0 Can you please tell which one? I assume it should be number 3. Yes (again, IMO). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment: Started implementing accept4() socket method and stuck on socket object's timeout attribute. What value should we assign to sock-sock_timeout if SOCK_NONBLOCK was specified in accept4() call? And in socket.py should we check as in original accept: if getdefaulttimeout() is None and self.gettimeout(): sock.setblocking(True) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Charles-François Natali neolo...@free.fr added the comment: No one seems to object, and since this approach has been suggested by Martin and is consistent with the posix module's policy (i.e. a thin wrapper around the underlying syscall), I guess you can go ahead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Vetoshkin Nikita nikita.vetosh...@gmail.com added the comment: Yes, I can. We decided to expose accept4() as another socket method, not accept() replacement? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Charles-François Natali neolo...@free.fr added the comment: @nvetoshkin Could you update your patch against py3k? I've got a couple comments (can't login to Rietveld, it's probably due to the change of my tracker account name): if(flags ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) { PyErr_SetString(PyExc_ValueError, Wrong flag value); return NULL; } I'm not sure that's necessary: - accept4() can sanitize its input itself if necessary (will fail with EINVAL) - if some flag is added, or another OS doesn't use the same flags, it'll fall out of sync #ifdef HAVE_ACCEPT4 /* These flags are not inherited after accept */ type = ~(SOCK_NONBLOCK SOCK_CLOEXEC); #endif /* HAVE_ACCEPT4 */ SOCK_NONBLOCK SOCK_CLOEXEC == 0, so this doesn't do much. Second, you should probably reuse what's done in Lib/socket.py for timeout inheritance upon accept (except that here you certainly don't want to set the socket to blocking if SOCK_NONBLOCK flag is passed). You should add a test for that: have a look at test_pipe2 in Lib/test/test_posix.py. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +charles-francois.natali, haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Antoine Pitrou pit...@free.fr added the comment: Duplicated in issue11157. -- nosy: +mmarkk ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10115] Support accept4() for atomic setting of flags at socket creation
Antoine Pitrou pit...@free.fr added the comment: I've removed the accept4() call in the meantime (in r85796), so that this issue can be re-classified as a feature request. -- priority: critical - normal title: accept4 can fail with errno 90 - Support accept4() for atomic setting of flags at socket creation type: behavior - feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com