Reduce critical section when writing with TCPMux

To avoid one bad connection causing locked processes/cascading failures.
This commit is contained in:
David Zhao
2022-04-05 23:25:38 -07:00
parent 34be706c11
commit b73472ee7e
+2 -2
View File
@@ -149,9 +149,9 @@ func (t *tcpPacketConn) ReadFrom(b []byte) (n int, raddr net.Addr, err error) {
// WriteTo is for active and s-o candidates.
func (t *tcpPacketConn) WriteTo(buf []byte, raddr net.Addr) (n int, err error) {
t.mu.Lock()
defer t.mu.Unlock()
conn, ok := t.conns[raddr.String()]
t.mu.Unlock()
if !ok {
return 0, io.ErrClosedPipe
// conn, err := net.DialTCP(tcp, nil, raddr.(*net.TCPAddr))