-
Notifications
You must be signed in to change notification settings - Fork 27
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
handle timeouts using i/o deadlines. #48
base: master
Are you sure you want to change the base?
Conversation
Both initiator and responder now time out if reads and/or writes are blocked for 30 seconds (default negotiation timeout). Introduces two tests to validate the new behaviour. Fixes #47.
This fails CI because of libp2p/go-libp2p#736. |
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.
Note: IMO, the real issue is libp2p/go-libp2p#738.
(although canceling here as well is probably a good idea anyways)
} | ||
if err2 != nil { | ||
return err2 | ||
if clearFn, err := setDeadline(rwc); err != nil { |
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.
So, many connections implement net.Conn
(and SetDeadline
) but don't actually implement it (and instead return an error). This is why we do things like https://github.com/libp2p/go-libp2p-transport-upgrader/blob/0d4065ec7151149beef41f3a8b1fbf6978ed12dc/upgrader.go#L111-L132.
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.
Note: we could detect and handle os.ErrNoDeadline
.
"time" | ||
) | ||
|
||
// NegotiationTimeout is the maximum time a protocol negotiation atempt is |
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.
s/atempt/attempt
Both initiator and responder now time out if reads and/or writes are blocked for 30 seconds (default negotiation timeout).
Introduces two tests to validate the new behaviour.
Fixes #47.
Addresses filecoin-project/lotus#518.