Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncore does not handle EINTR in recv, send, connect, accept, #55475

Closed
socketpair mannequin opened this issue Feb 21, 2011 · 6 comments
Closed

asyncore does not handle EINTR in recv, send, connect, accept, #55475

socketpair mannequin opened this issue Feb 21, 2011 · 6 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@socketpair
Copy link
Mannequin

socketpair mannequin commented Feb 21, 2011

BPO 11266
Nosy @vstinner, @giampaolo, @socketpair
Superseder
  • bpo-18885: handle EINTR in the stdlib
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-07-24.16:36:25.826>
    created_at = <Date 2011-02-21.05:31:30.435>
    labels = ['type-bug', 'library']
    title = 'asyncore does not handle EINTR in recv, send, connect, accept,'
    updated_at = <Date 2014-07-24.16:36:25.825>
    user = 'https://github.com/socketpair'

    bugs.python.org fields:

    activity = <Date 2014-07-24.16:36:25.825>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-07-24.16:36:25.826>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2011-02-21.05:31:30.435>
    creator = 'socketpair'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 11266
    keywords = []
    message_count = 6.0
    messages = ['128940', '130015', '130103', '130104', '130106', '221748']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'giampaolo.rodola', 'segfaulthunter', 'nvetoshkin', 'socketpair']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '18885'
    type = 'behavior'
    url = 'https://bugs.python.org/issue11266'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2', 'Python 3.3']

    @socketpair
    Copy link
    Mannequin Author

    socketpair mannequin commented Feb 21, 2011

    in spite of usage of non-blocking IO, syscalls may return EINTR if signal arrive during some syscalls.

    It is desirable to re-call syscall after receiving EINTR. Trivial loops should be implemented around (recv, send, connect, accept)

    @socketpair socketpair mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 21, 2011
    @giampaolo
    Copy link
    Contributor

    Again, it's not clear to me what you are complaining about.
    Please try to be more clear and/or provide a patch.

    @socketpair
    Copy link
    Mannequin Author

    socketpair mannequin commented Mar 5, 2011

    When using non-blocking IO, we issue select (or poll,epoll), and after that kernel should guarantee, that recv or send will complete immediatelly, transferring data as needed. But sometimes (as Linux is buggy), such operations results in EINTR error if some signal arrived during this call. In that case python exception generated and typically connection will be closed.
    To recover from this situation it is OK to call recv or send again in case of EINTR. All network functions (recv*, send*, accept, connect) are vulnerable for EINTR in practice.

    @socketpair
    Copy link
    Mannequin Author

    socketpair mannequin commented Mar 5, 2011

    http://unix.derkeiler.com/Mailing-Lists/FreeBSD/hackers/2008-02/msg00457.html

    Okay, linux is not buggy :)))
    EINTR may occur if SA_RESTART is not specified in sigaction.

    @nvetoshkin
    Copy link
    Mannequin

    nvetoshkin mannequin commented Mar 5, 2011

    Here's a similar bug: http://bugs.python.org/issue7978.

    EINTR may occur if SA_RESTART is not specified in sigaction.
    Some syscalls (like select) will generate EINTR despite SA_RESTART. man 7 signal

    @vstinner
    Copy link
    Member

    It was already discussed in other issues, the issue is not specific to asyncore: Python code should not handle EINTR. IMO the C module socket should handle EINTR for you.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants