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: Check errno of epoll_ctrl
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, shaovie
Priority: normal Keywords:

Created on 2009-09-09 02:13 by shaovie, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg92441 - (view) Author: shaowei.cui (shaovie) Date: 2009-09-09 02:13
in selectmodule.c, I found the code of epoll module
'        result = epoll_ctl(epfd, op, fd, &ev);
        if (errno == EBADF) {
            /* fd already closed */
            result = 0;
            errno = 0;
        }
'
'man epoll_ctl' show 'EBADF  epfd or fd is not a valid file
descriptor.', assume I register an fd of 'open('xxx', O_RDONLY)', return
value will be -1, errno will be EBADF,  
epoll not support 'file descriptors.' as i know,  or i register an fd
was not be opened.
msg202292 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2013-11-06 22:17
I don't understand the bug being reported.  The code you quote should 
probably be written as "if (result < 0 && errno == EBADF)", but the block's net effect is to ignore an error by resetting result and errno.  
It doesn't matter if we occasionally set result and errno to 0 when result is already zero, but errno happens to be set to EBADF from some earlier operation.

The open('xxx', O_RDONLY) would raise an exception, not return a fd of -1, so I don't see how that can be used to trigger a problem.

Therefore I'll close this issue, but am willing to re-open it if someone can explain a way this code could actually cause problems.
History
Date User Action Args
2022-04-11 14:56:52adminsetgithub: 51117
2013-11-06 22:17:49akuchlingsetstatus: open -> closed

nosy: + akuchling
messages: + msg202292

resolution: wont fix
stage: test needed -> resolved
2010-07-11 09:36:58BreamoreBoysetstage: test needed
versions: + Python 2.7, Python 3.2
2009-09-09 02:13:09shaoviecreate