Skip to content

Remove state() and can_send() from SSL #150

Description

@SeanTAllen

Every SSL method already does the right thing regardless of state — read() returns None when there's nothing to read, write() raises when writing isn't possible, receive() drops data when the session is dead. state() exists so consumers can ask the session what state it's in and branch on the answer, but the methods already answer through their return values.

can_send() is the same pattern: it asks whether send() has data, but send() already raises when there's nothing to send. The while can_send() do send() end loop is just a try/while on send() with an extra round trip.

SSLConnection._poll has three match _ssl.state() blocks and two while _ssl.can_send() loops that duplicate decisions the SSL session already handles through its methods.

_Closed.read() also calls ssl.state() internally to check whether _do_read transitioned to SSLError, so there's an internal dependency to rework too.

SSLConnection currently discovers three transitions by polling state: handshake complete (to call connected/accepted), auth failed (to call auth_failed), and session closed. Those need a different mechanism.

Once state() is gone, _AuthFailed and _Errored are identical — their only difference is the state() return value. Whether they collapse into one class depends on how the auth-failed notification is redesigned. Removing state() also removes SSLState and the six state primitives in ssl_state.pony.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions