-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
bpo-31922: Do not connect UDP sockets when broadcast is allowed #423
Conversation
6560c49
to
8cf33a2
Compare
8cf33a2
to
121e878
Compare
Vincent, could you please rebase your PR? If @asvetlov approves this can go into 3.7.1. |
9e956af
to
c1557f4
Compare
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
c1557f4
to
8d99e61
Compare
@asvetlov @1st1 The macOS CI fails with the following error:
I suspect it is related to the following change: @@ -992,10 +997,7 @@ class _SelectorDatagramTransport(_SelectorTransport):
if not self._buffer:
# Attempt to send it right away first.
try:
- if self._address:
- self._sock.send(data)
- else:
- self._sock.sendto(data, addr)
+ self._sock.sendto(data, addr) However, I have no idea why |
After some investigation I realized that using
Similar issues:
I'll update the PR. |
a303db1
to
459aced
Compare
AppVeyor failed with:
I have a good news for you: it's your lucky day! @1st1 and me already identified this bug and it's already fixed in 3.7 and master branches! Please rebase your change on top of master. FYI the bug was: https://bugs.python.org/issue33803 |
459aced
to
d0edc3b
Compare
Hi @vstinner, the CI is fixed, thanks! |
d0edc3b
to
1b99435
Compare
1b99435
to
4f63bb5
Compare
This fixes asyncio issue python#480. The _SelectorDatagramTransport.sendto method has to be modified so _sock.send is used only if _sock is connected. It also protects socket.getsockname against OSError in _SelectorTransport. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting).
4f63bb5
to
3b4b16b
Compare
Sorry, I can't merge this PR. Reason: |
1 similar comment
Sorry, I can't merge this PR. Reason: |
Thanks @vxgmichel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
…onGH-423) *Moved from python/asyncioGH-493.* This PR fixes issue python/asyncioGH-480, as explained in [this comment](https://github.com/python/asyncio/issues/480GH-issuecomment-278703828). The `_SelectorDatagramTransport.sendto` method has to be modified ~~so `_sock.sendto` is used in all cases (because it is tricky to reliably tell if the socket is connected or not). Could that be an issue for connected sockets?~~ *EDIT* ... so `_sock.send` is used only if `_sock` is connected. It also protects `socket.getsockname` against `OSError` in `_SelectorTransport`. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting). https://bugs.python.org/issue31922 (cherry picked from commit 63deaa5) Co-authored-by: Vincent Michel <[email protected]>
GH-13162 is a backport of this pull request to the 3.7 branch. |
Thanks and sorry for long waiting. |
*Moved from python/asyncioGH-493.* This PR fixes issue python/asyncioGH-480, as explained in [this comment](https://github.com/python/asyncio/issues/480GH-issuecomment-278703828). The `_SelectorDatagramTransport.sendto` method has to be modified ~~so `_sock.sendto` is used in all cases (because it is tricky to reliably tell if the socket is connected or not). Could that be an issue for connected sockets?~~ *EDIT* ... so `_sock.send` is used only if `_sock` is connected. It also protects `socket.getsockname` against `OSError` in `_SelectorTransport`. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting). https://bugs.python.org/issue31922 (cherry picked from commit 63deaa5) Co-authored-by: Vincent Michel <[email protected]>
Moved from python/asyncio#493.
This PR fixes issue python/asyncio#480, as explained in this comment.
The
_SelectorDatagramTransport.sendto
method has to be modifiedsoEDIT ... so_sock.sendto
is used in all cases (because it is tricky to reliably tell if the socket is connected or not). Could that be an issue for connected sockets?_sock.send
is used only if_sock
is connected.It also protects
socket.getsockname
againstOSError
in_SelectorTransport
. This might happen on Windows if the socket is not connected (e.g. for UDP broadcasting).https://bugs.python.org/issue31922