-
-
Notifications
You must be signed in to change notification settings - Fork 38
Handle EOF when DuplexStream is closed, avoiding a panic. #77
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,7 +331,9 @@ pub async fn build_ble_stream( | |
| // Data from user, forward it to the device | ||
| from_server = server.read(&mut buf) => { | ||
| let len = from_server.map_err(duplex_write_error_fn)?; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated, but I notice on this read error you map_err using a write error fn, and the same at line 308
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, the name is wrong, I can change it later. |
||
| ble_handler.write_to_radio(&buf[..len]).await?; | ||
| if len != 0 { | ||
| ble_handler.write_to_radio(&buf[..len]).await?; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can also return I can look into this later, you can merge this PR as it is an improvement.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will have to merge it I think.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the result of an explicit disconnect call, strictly speaking not an error - but will let you decide. |
||
| } | ||
| }, | ||
| event = adapter_events.next() => { | ||
| if Some(AdapterEvent::Disconnected) == event { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this: