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

Retry on WANT_WRITE & WANT_READ in sendall() #954

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Jan 23, 2024

  1. Retry on WANT_WRITE & WANT_READ in sendall()

    This change introduces retries in `OpenSSL.SSL.Connection.sendall()`
    when `WANT_WRITE_ERROR` or `WANT_READ_ERROR` happen.
    
    It relies on `SSL_MODE_ENABLE_PARTIAL_WRITE` being set on the context,
    that changes the mode of `SSL_write()` to return errors only if zero
    bytes has been sent making it safe to retry in these cases.
    
    Ideally, the calling code is supposed to `poll()`/`select()` the
    socket to know when it's okay to attempt the next retry (hence it is
    readable or writable) but it's not available in the `sendall()` method
    and just retrying the operation is good enough.
    
    Fixes pyca#176
    
    Refs:
    * http://openssl.6102.n7.nabble.com/SSL-MODE-ACCEPT-MOVING-WRITE-BUFFER-td6421.html
    * https://stackoverflow.com/a/28992313/595220
    * https://www.openssl.org/docs/manmaster/man3/SSL_write.html
    * https://stackoverflow.com/a/20817394/595220
    webknjaz committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    9836c42 View commit details
    Browse the repository at this point in the history