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/asynchat hangs when used with ssl sockets #61180

Closed
AnthonyLozano mannequin opened this issue Jan 15, 2013 · 4 comments
Closed

Asyncore/asynchat hangs when used with ssl sockets #61180

AnthonyLozano mannequin opened this issue Jan 15, 2013 · 4 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@AnthonyLozano
Copy link
Mannequin

AnthonyLozano mannequin commented Jan 15, 2013

BPO 16976
Nosy @giampaolo
Files
  • asychat_fix.py
  • 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-06-22.10:12:46.261>
    created_at = <Date 2013-01-15.22:02:45.347>
    labels = ['type-bug']
    title = 'Asyncore/asynchat hangs when used with ssl sockets'
    updated_at = <Date 2014-06-22.10:12:46.260>
    user = 'https://bugs.python.org/AnthonyLozano'

    bugs.python.org fields:

    activity = <Date 2014-06-22.10:12:46.260>
    actor = 'giampaolo.rodola'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-06-22.10:12:46.261>
    closer = 'giampaolo.rodola'
    components = ['None']
    creation = <Date 2013-01-15.22:02:45.347>
    creator = 'Anthony.Lozano'
    dependencies = []
    files = ['28746']
    hgrepos = []
    issue_num = 16976
    keywords = []
    message_count = 4.0
    messages = ['180058', '180061', '221209', '221244']
    nosy_count = 3.0
    nosy_names = ['giampaolo.rodola', 'BreamoreBoy', 'Anthony.Lozano']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16976'
    versions = ['Python 2.7']

    @AnthonyLozano
    Copy link
    Mannequin Author

    AnthonyLozano mannequin commented Jan 15, 2013

    If you create a asynchat subclass with a SSL socket asyncore can hang when data larger than the ac_in_buffer_size comes in.

    What (I think) happens is that asyncore uses a select.select call to determine when to read more data from the socket. On the first call, this will correctly see that there is data to recv and we will continue on to the handle_read function in asynchat. Once there, if there is more than ac_in_buffer_size data to read, handle_read will not find the terminator, and thus not call find_terminator, expecting to find it on the next pass with another self.recv. Unfortunately, the SSL wrapped socket will not play nicely with next select call (the one that should be triggering the next handle_read) because the ssl socket might internally read more data, and select is looking at the raw socket which is empty now thanks to ssl (at least according to an answer here: http://stackoverflow.com/questions/3187565/select-and-ssl-in-python).

    A solution would be to check the if the socket has any data pending with the sslsock.pending() method and read the rest out. I am doing this in the handle_read function of my child class as attached, but I don't know if that's a generic enough solution for everyone.

    @AnthonyLozano AnthonyLozano mannequin added type-crash A hard crash of the interpreter, possibly with a core dump type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Jan 15, 2013
    @giampaolo
    Copy link
    Contributor

    asyncore simply does not support SSL.
    That is tracked in bpo-10084.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 21, 2014

    As bpo-10084 has been closed "won't fix" then the same must apply here.

    @giampaolo
    Copy link
    Contributor

    Yes.

    @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
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant