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

handle timeouts using i/o deadlines. #48

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

handle timeouts using i/o deadlines. #48

wants to merge 1 commit into from

Conversation

raulk
Copy link
Member

@raulk raulk commented Nov 1, 2019

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.

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.
@raulk
Copy link
Member Author

raulk commented Nov 1, 2019

This fails CI because of libp2p/go-libp2p#736.

Copy link
Member

@Stebalien Stebalien left a 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 {
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/atempt/attempt

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.

multistream-select v1 does not handle timeouts
4 participants