Skip to content

Gracefully handle socket creation failure #83

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

Closed
wants to merge 2 commits into from

Conversation

tjstum
Copy link

@tjstum tjstum commented Nov 21, 2019

It is possible that the call to create a regular socket fails, even
before you try to do anything with it. In those cases, we should allow
another attempt to succeed.

One way that this can happen is on linux with ipv6.disable=1 on the
kernel command line. In this case, opening a socket with an IPv6
address family will fail with EAFNOSUPPORT.

@tjstum
Copy link
Author

tjstum commented Nov 21, 2019

I'm happy to add a test for this if you can give me some guidance about how you'd like to simulate such an error (I could monkeypatch socket.socket, but that may be controversial)

It is possible that the call to create a regular socket fails, even
before you try to do anything with it. In those cases, we should allow
another attempt to succeed.

One way that this can happen is on linux with `ipv6.disable=1` on the
kernel command line. In this case, opening a socket with an IPv6
address family will fail with EAFNOSUPPORT.
@agronholm
Copy link
Owner

What's wrong about using monkey patching in tests?

@tjstum
Copy link
Author

tjstum commented Nov 21, 2019

Nothing! I just wanted to make sure that was an approach you'd endorse. I'll update the branch to include a test later.

I'm also unsure about the CI checks there. It seems that the CI doesn't run against master? The badge on README suggests that they're not running, and the only builds on the Azure Pipeline page seems to be mine. I'm not sure I understand how this change would cause the test failures reported there. I can dig further later today, but I figured I'd ask if there's some known issue.

@agronholm
Copy link
Owner

git checkout --progress --force refs/remotes/pull/83/merge <- this is what it does, should be right, yes?

@agronholm
Copy link
Owner

The previous builds seem to have gone – no idea where to.

@agronholm
Copy link
Owner

The tests would be very welcome. If you can prove that this patch actually fixes something, I will merge it right away.

The failure of the test suite is due to some change in trio 0.13. It passes fine on 0.12.1.

@tjstum
Copy link
Author

tjstum commented Nov 25, 2019

Yeah, I do plan to add the tests. I just haven't had a moment to do it yet.

What do you want me to do regarding the CI failure, if anything?

@agronholm
Copy link
Owner

What do you want me to do regarding the CI failure, if anything?

If you look at the CI status now, you can see that it's passing because I fixed the problems (introduced by trio 0.13) and updated this PR to match.

@agronholm
Copy link
Owner

I couldn't wait any longer so I just made my own patch and tests. Thanks for the heads up though.

@tjstum
Copy link
Author

tjstum commented Nov 27, 2019

Thanks! Sorry for the delay. It's just been a busy week for me.

I might still have a go at adding tests that simulate the exact issue I had (which is basically limited just to sockets created with AF_INET6 on linux kernels that have ipv6 globally disabled) if you're interested.

@agronholm
Copy link
Owner

I might still have a go at adding tests that simulate the exact issue I had (which is basically limited just to sockets created with AF_INET6 on linux kernels that have ipv6 globally disabled) if you're interested.

Nah, the test I added covers that case just fine.

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