Write deadlock fixes and overall reliability improvements #30
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.
I have noticed that in some scenarios socket write(like here) can hang for indefinite time.
At least it reproducible in the latest MacOS release(13.2) when writing on some standard network interfaces.
In this case it blocks all the further writes to other interface and deadlock Shutdown
This PR introduce
WriteTimeoutandClientWriteTimeoutoption with default of 10 sec. It seems to be much more than ok. In my case it either writes under 10ms or hangs indefinitelyOverall if it will be timeout'ed we still have 3 tries in the probe
NetInterfacethat alongside the net.Interface stores the bitmask flagsMulticastJoinedandMessageSentseparately for IPv6 and IPv4.The reason behind this is that multicastResponse call without interface specified works in a way it iterates through all interface to send the message. This makes unregister tries to connect to interfaces that can be failed to join multicast group or send the announce - which is make no sense
On macOS I faced situations where some interface can join IPv6 multicast but can't join IPv4 multicast, or can announce on IPv6 but always hang(timeout) during announceText.
So
multicastResponsenow has an optional arguments to pass required flagsServerSelectIPTrafficoption similar to client'sSelectIPTrafficoption to disable IPv6 or IPv4 multicast.This seems pretty useful to have, because you have no other way to control it, and IPv6 multicast may be more tricky to support