Problem: can't unbind with bound addr with IPv6 #1902
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solution: un-break un-binding a socket with the same endpoint string that was used to bind it when IPv6 is enabled. The breakage was caused by using the actual last_endpoint as a key instead of the string passed by the user, which is necessary in the wildcard case. But it broke the normal case with IPv6, since even if the address is an IPv4 one it will be saved in IPv6 format, so it doesn't match anymore. This is the culprit: 09e7416
My solution is a liiitle bit of a hack - basically I try to use the used-provided endpoint string and resolve it, just like it's used in connect/bind case, and see if that succeeds before giving up. At least it should be future-proof, and if more changes are done to the connect/bind they should be picked up in the unbind/disconnect. And the existing API for wildcard sockets is maintained, nothing is broken.
Also added a bunch of tests for various combinations of TCP sockets endpoints. Note that Travis on Precise (legacy) or Trusty does not support IPv6, so I added a test run on the container-based environment which is the only one that has a loopback interface with ::1 bound on it, so IPv6 test cases can run there. Note that I can't test this on Windows - I think it should work as I've used the same options as in existing part of the library.
Fixes zeromq/zeromq4-1#114