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

use x/sys/unix instead of syscall to fix EpollWait on Android #18

Merged
merged 3 commits into from
Nov 12, 2019

Conversation

jakubgs
Copy link
Contributor

@jakubgs jakubgs commented Nov 10, 2019

I encountered an issue while working on something using tcp-shaker which affects the arm64 platform. Specifically the EpollWait call returns an EpollEvent with the file descriptor set to 0.
This is the case for every flag configuration I've tried.

I've reported the issue in golang/go#35479 but as the syscall package has been frozen since Go 1.3 it most probably won't be fixed. But what I did find out is that the x/sys/unix package is an up-to-date drop-in replacement for the syscall package, and one that doesn't have this bug.

So here's a PR that replaces use of syscall with x/sys/unix to fix the Android issue.

@jakubgs
Copy link
Contributor Author

jakubgs commented Nov 10, 2019

I actually didn't notice this before, but the syscall package page does have a deprecation warning:

Deprecated: this package is locked down. Callers should use the corresponding package in the golang.org/x/sys repository instead. That is also where updates required by new systems or versions should be applied. See https://golang.org/s/go1.4-syscall for more information.
https://golang.org/pkg/syscall/

Though its visibility could be improved...

@tevino
Copy link
Owner

tevino commented Nov 11, 2019

@jakubgs Thanks for your PR.

The package is not dependency-free after using golang.org/x/sys/unix, could you please make it a module? CI should be passed after that.

@jakubgs jakubgs force-pushed the fix-android branch 2 times, most recently from 711c0ed to 6dbc170 Compare November 11, 2019 10:44
@jakubgs
Copy link
Contributor Author

jakubgs commented Nov 11, 2019

Ah, you're absolutely right, forgot about that. Here you go.

@tevino tevino merged commit 5aa79ae into tevino:master Nov 12, 2019
@tevino
Copy link
Owner

tevino commented Nov 12, 2019

@jakubgs Thanks for your work, it would be awesome if you could make it work on Darwin as well.

@jakubgs
Copy link
Contributor Author

jakubgs commented Nov 12, 2019

Yeah, I already have it working on Darwin, see my support-darwin branch. But it's not working how it's supposed to. It's not sending the RST packet fast enough, so it becomes SYN > SYN-ACK > ACK > RST. I think it's the lack of TCP_QUICKACK flag for the socket, but I'm not 100% sute.

I'll do some more research but for my purposes that's good enough. I'll submit a PR today or tomorrow. Maybe someone else can come along and fix it, since I don't know how to make it work.

@tevino
Copy link
Owner

tevino commented Nov 12, 2019

@jakubgs I just tried the latest HAProxy(2.0.7), turns out it still couldn't send the RST ahead of time on Darwin.

If the best we could achieve on Darwin is a normal TCP handshake, the current implementation(net.Dial) should do the work.

@tevino
Copy link
Owner

tevino commented Nov 12, 2019

Yes, the lack of TCP_QUICKACK is the reason that we could not make it cross-platform, I should have written about it in the documentation.

However, now I have forgotten the details of my previous research, if you could add some conclusions about yours that would be awesome, given that you have done a great deal of elaboration here.

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.

2 participants