Skip to content

Commit b56bd05

Browse files
committed
Rename SSLReceiveOK to SSLAccepted, add InvalidOperation
SSLReceiveOK named the plumbing; SSLAccepted says what happened. InvalidOperation signals a call on a session that is no longer operational — _Disposed.receive and _Disposed.read return it instead of silently pretending the operation succeeded.
1 parent cb64154 commit b56bd05

6 files changed

Lines changed: 116 additions & 56 deletions

File tree

.release-notes/next-release.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Replace state polling with return values from receive, read, and send
66

7-
`state()`, `can_send()`, `SSLState`, `SSLHandshake`, and `SSLDisposed` are removed. The return values of `receive()`, `read()`, and `send()` carry the outcome of each operation.
7+
`state()`, `can_send()`, `SSLState`, `SSLHandshake`, and `SSLDisposed` are removed. The return values of `receive()`, `read()`, and `send()` carry the outcome of each operation. `InvalidOperation` signals a call on a session that is no longer operational (disposed).
88

99
`receive(data)` returns `SSLReceiveResult`:
1010

@@ -21,10 +21,11 @@ end
2121
2222
// After
2323
match ssl.receive(data)
24-
| SSLReceiveOK => None
24+
| SSLAccepted => None
2525
| SSLReady => // ...
2626
| SSLAuthFail => // ...
2727
| SSLError => // ...
28+
| InvalidOperation => // ...
2829
end
2930
```
3031

@@ -43,6 +44,7 @@ match ssl.read()
4344
| None => // ...
4445
| SSLClosed => // ...
4546
| SSLError => // ...
47+
| InvalidOperation => // ...
4648
end
4749
```
4850

ssl/net/_ssl_session_state.pony

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class _Handshaking is _SSLSessionState
3232
class _Ready is _SSLSessionState
3333
fun ref receive(ssl: SSL ref, data: ByteSeq): SSLReceiveResult =>
3434
ssl._do_receive(data)
35-
SSLReceiveOK
35+
SSLAccepted
3636

3737
fun ref read(ssl: SSL ref, expect: USize): SSLReadResult =>
3838
ssl._do_read(expect)
@@ -60,14 +60,15 @@ class _Closing is _SSLSessionState
6060

6161
fun ref receive(ssl: SSL ref, data: ByteSeq): SSLReceiveResult =>
6262
ssl._do_receive(data)
63-
SSLReceiveOK
63+
SSLAccepted
6464

6565
fun ref read(ssl: SSL ref, expect: USize): SSLReadResult =>
6666
match \exhaustive\ ssl._do_read(expect)
6767
| let data: Array[U8] iso => consume data
6868
| None => SSLClosed
6969
| SSLClosed => SSLClosed
7070
| SSLError => SSLError
71+
| InvalidOperation => _Unreachable(); SSLError
7172
end
7273

7374
fun ref write(ssl: SSL ref, data: ByteSeq) ? => error
@@ -91,7 +92,7 @@ class _Closed is _SSLSessionState
9192

9293
fun ref receive(ssl: SSL ref, data: ByteSeq): SSLReceiveResult =>
9394
ssl._do_receive(data)
94-
SSLReceiveOK
95+
SSLAccepted
9596

9697
fun ref read(ssl: SSL ref, expect: USize): SSLReadResult =>
9798
let result = ssl._do_read(expect)
@@ -101,6 +102,7 @@ class _Closed is _SSLSessionState
101102
| None => SSLClosed
102103
| SSLClosed => SSLClosed
103104
| SSLError => SSLError
105+
| InvalidOperation => _Unreachable(); SSLError
104106
end
105107

106108
fun ref write(ssl: SSL ref, data: ByteSeq) ? => error
@@ -118,9 +120,9 @@ class _Closed is _SSLSessionState
118120

119121
class _Disposed is _SSLSessionState
120122
fun ref receive(ssl: SSL ref, data: ByteSeq): SSLReceiveResult =>
121-
SSLReceiveOK
123+
InvalidOperation
122124

123-
fun ref read(ssl: SSL ref, expect: USize): SSLReadResult => None
125+
fun ref read(ssl: SSL ref, expect: USize): SSLReadResult => InvalidOperation
124126

125127
fun ref write(ssl: SSL ref, data: ByteSeq) => None
126128

0 commit comments

Comments
 (0)