Commit 20ea6a0
Handle unexpected EOF as expected in session closure (#495)
Fixes: #253
My session was hitting the following error after receiving a
`DISCONNECT` message from the client.
```
IO(Custom { kind: UnexpectedEof, error: "early eof" })
```
On closer inspection (and thanks to the issue), I realized it was coming
from the shutdown process of the session. I believe the intention here
is to break when we hit eof (read 0 bytes):
https://github.com/Eugeny/russh/blob/89fed88265b402e7d505025c42f4e19ab12201f3/russh/src/server/session.rs#L650
but because of this line in the called read function
https://github.com/Eugeny/russh/blob/89fed88265b402e7d505025c42f4e19ab12201f3/russh/src/cipher/mod.rs#L254
reading 0 bytes will always be an UnexpectedEOF error. This might be
good to fully propagate the error other places in the code, but here it
makes sense to catch it and process it as an expected EOF.
I kept in the n == 0 check but I doubt we'd ever see that case fire
since it would mean that we received an empty ssh message and I'd
imagine the reason this loop exists is to make sure we're not missing
any actual messages while we wait for everything to shut down.
---------
Co-authored-by: Eugene <[email protected]>1 parent 154f820 commit 20ea6a0
1 file changed
+9
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
654 | 659 | | |
655 | 660 | | |
656 | 661 | | |
| |||
0 commit comments