Skip to content

implement ContextDial, make connect respect context cancellation - #16

Closed
whyrusleeping wants to merge 9 commits into
libp2p:masterfrom
whyrusleeping:feat/context-dial
Closed

whyrusleeping wants to merge 9 commits into
libp2p:masterfrom
whyrusleeping:feat/context-dial

Conversation

@whyrusleeping

Copy link
Copy Markdown
Contributor

This uses contexts to make the reuseport dialer respect contexts for cancellation of dials.

Comment thread impl_unix.go Outdated
case <-success:
return
default:
poller.Close()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think this really has any effect...

@whyrusleeping

Copy link
Copy Markdown
Contributor Author

cc @Kubuxu for review

@Kubuxu

Kubuxu commented Aug 18, 2016

Copy link
Copy Markdown
Member

Travis failed but it probably is SO_REUSEPORT + port 0 collision.

LGTM.

@whyrusleeping

whyrusleeping commented Aug 18, 2016 •

Copy link
Copy Markdown
Contributor Author

Yeah, it fails occasionally locally for me. But it appears to just be SO_REUSEPORT being SO_REUSEPORT and trying to reuse a port that the system is using.

Comment thread impl_unix.go Outdated
func connect(fd int, ra syscall.Sockaddr, deadline time.Time) error {
func connect(ctx context.Context, fd int, ra syscall.Sockaddr, deadline time.Time) error {
// NOTE: We currently only use the context to pass in a deadline.
// Canceling an epoll_wait call is hard.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so it doesn't work with a cancel() call, right? i'd be wary of this-- then-- because it doesn't really respect ctx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we still don't have a good way to use this purely via cancel. This does however let us pass the contexts timeout down farther, which is helpful

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a bit cheaty but it might work, adding a UDP socket to epoll_wait group and using it as wakeup call. It might work with just one socket and SO_REUSEPORT but fifo probably would work as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other option is epoll_pwait and pthread_kill.

@Kubuxu

Kubuxu commented Sep 16, 2016 •

Copy link
Copy Markdown
Member

Please include my last commit: Kubuxu@00e722d

I fixed eventfd locally but didn't push it.

@Kubuxu

Kubuxu commented Sep 17, 2016

Copy link
Copy Markdown
Member

@whyrusleeping you didn't add my recent commits at the https://github.com/Kubuxu/go-reuseport/tree/feat/context-dial

@whyrusleeping

Copy link
Copy Markdown
Contributor Author

closing, no longer needed

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.

3 participants