Skip to content
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

Treat UnexpectedEof as Disconnect #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tecywiz121
Copy link

After the other end of a unix domain socket or a pipe disconnects, calls to read_exact will return an UnexpectedEof error.

I believe that this should be treated as an ErrorKind::Disconnect and not a generic ErrorKind::Failure.

@dwrensha
Copy link
Member

dwrensha commented May 4, 2019

Thanks!

In the context of the RPC system, I agree that ErrorKind::Disconnect seems appropriate for this sort of error. But what if the (truncated) message is being read from disk? ErrorKind::Disconnect seems inappropriate in that case.

Maybe what we should really be doing is looking into wrapping errors more faithfully, as e.g. the failure crate might allow us to do.

@tecywiz121
Copy link
Author

What would ErrorKind::Disconnect mean when reading from disk? That the file was deleted?

I've been using snafu lately, and been enjoying it, but you can avoid pulling in an external crate if all you want to do is wrap the error type: just add a variant with the error type and implement std::error::Error.

@dwrensha
Copy link
Member

I've added a try_read_message() function in 18c2e0c. The idea is that you can call this function in a loop and stop when it return None, which means EOF. Does that address your concern?

@tecywiz121
Copy link
Author

I'm no longer working on the project using this crate, but @JoelScarfone will probably have an opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants