Repository navigation
Conversation
On macOS with many multicast interfaces a burst of per-interface writes can wedge the shared UDP socket: sendmsg first fails with ENETUNREACH, then blocks forever. Server.Shutdown calls unregister, which multicasts synchronously, so it never returns and every caller hangs with it (e.g. ship-go's mdns tests time out after 10 minutes). Set a 100ms write deadline per packet and treat a deadline exceeded error like a gone interface, so the interface manager backs it off instead of stalling every following send. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On macOS with many multicast interfaces (here 22:
anpi*,en*,awdl0,llw0,utun*), a burst of per-interface multicast writes on one shared UDP socket can wedge that socket.sendmsgfirst fails withENETUNREACH, then blocks forever. A fresh socket per interface and repeated writes on a single interface do not trigger it.Server.Shutdowncallsunregister, which sends the goodbye multicast synchronously, soShutdownnever returns. Every caller hangs with it. In ship-go,go test ./mdns/runs into the 10 minute test timeout, both ondev(zeroconf v2) and on enbility/ship-go#68 (v3):Fix
ipv4PacketConn.WriteToandipv6PacketConn.WriteToset a 100 ms write deadline per packet. A healthy send takes microseconds.isInterfaceGonetreatsos.ErrDeadlineExceededas gone.InterfaceManager.MarkFailedthen backs the interface off, so the next send does not stall on it again.Verification (macOS, behind a corporate VPN)
go test .: before,TestBasichit the timeout after 6m40s. After, the suite completes in 28 s.TestBasic,TestSubtypeandTestQuickShutdownstill fail on this machine because multicast does not work there. They are not hangs, andTestQuickShutdownfails ondevtoo.replace:go test ./mdns/before,Test_GoroutineLeakOnShutdownhung into the timeout. After, it completes in 76 s. Only the discovery assertions ofTest_ZeroConffail, for the same multicast reason.TestWriteToSetsDeadline(fails without the fix) andTestIsInterfaceGone_WriteDeadlineExceeded_ReturnsTrue.The existing
TestIsInterfaceGone_ETIMEDOUT_ReturnsFalsestill passes. A kernelETIMEDOUTstays transient. Only our own write deadline counts as gone.ship-go still pins zeroconf v2, so this reaches ship-go once enbility/ship-go#68 lands and picks up this commit.
🤖 Generated with Claude Code