vpnkit
vpnkit copied to clipboard
go: add deadlock detector, improve locking
We weren't fully compliant with the net.Conn interface as concurrent Write calls had problems:
- concurrent
Writecalls could exceed the allowed window size: one would see space available, drop the lock to write, allow a second to see the same space and write - concurrent
Writecalls could block: when the window is closed they would block inWait()but the window update message only usedSignal()and would only wake up one call, leaving the other blocked. It should useBroadcast().
The Write() timeout handling was strange because it offloaded the Wait() to a goroutine. It's simpler to keep the Wait() on the main goroutine and do a Broadcast() from an AfterFunc. It's also good to stop the timer in the common case where you don't need it, rather than leave them to build up.
Also
- add a deadlock detector
- update the logging library
- ensure the tests run on Windows