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.
Every
SSLmethod already does the right thing regardless of state —read()returnsNonewhen 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 whethersend()has data, butsend()already raises when there's nothing to send. Thewhile can_send() do send() endloop is just atry/whileonsend()with an extra round trip.SSLConnection._pollhas threematch _ssl.state()blocks and twowhile _ssl.can_send()loops that duplicate decisions the SSL session already handles through its methods._Closed.read()also callsssl.state()internally to check whether_do_readtransitioned toSSLError, so there's an internal dependency to rework too.SSLConnectioncurrently discovers three transitions by polling state: handshake complete (to callconnected/accepted), auth failed (to callauth_failed), and session closed. Those need a different mechanism.Once
state()is gone,_AuthFailedand_Erroredare identical — their only difference is thestate()return value. Whether they collapse into one class depends on how the auth-failed notification is redesigned. Removingstate()also removesSSLStateand the six state primitives inssl_state.pony.