We weren't fully compliant with the net.Conn interface as concurrent Write calls had problems:
concurrent Write calls 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 Write calls could block: when the window is closed they would block in Wait() but the window update message only used Signal() and would only wake up one call, leaving the other blocked. It should use Broadcast().
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.
We weren't fully compliant with the
net.Conn
interface as concurrentWrite
calls had problems:Write
calls 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 writeWrite
calls 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 theWait()
to a goroutine. It's simpler to keep theWait()
on the main goroutine and do aBroadcast()
from anAfterFunc
. 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