Skip to content

Commit

Permalink
udpmux: rmv vend() fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Aug 30, 2024
1 parent eb00852 commit d9344f6
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions intra/udpmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,6 @@ func (x *muxer) newLocked(r netip.AddrPort) *demuxconn {
}
}

// TODO: make sure a conn can only be vend once
func (x *muxer) vend(dst netip.AddrPort) (net.Conn, error) {
c := x.route(dst)
if c == nil {
log.E("udp: mux: %s vend: no conn for %s", x.cid, dst)
return nil, errUdpSetupConn
}
return c, nil
}

// Read implements core.UDPConn.Read
func (c *demuxconn) Read(p []byte) (int, error) {
defer c.rt.Reset(c.rto)
Expand Down Expand Up @@ -507,8 +497,14 @@ func (e *muxTable) associate(cid, pid string, src, dst netip.AddrPort, mk assocF
return nil, errProxyMismatch // return
}

e.Unlock() // unlock
return mxr.vend(dst) // do not hold e.lock on calls into mxr
e.Unlock() // unlock
// do not hold e.lock on calls into mxr
c = mxr.route(dst)
if c == nil {
log.E("udp: mux: %s vend: no conn for %s", mxr.cid, dst)
return nil, errUdpSetupConn
}
return c, nil
}

func (e *muxTable) dissociate(cid, pid string, src netip.AddrPort) {
Expand Down

1 comment on commit d9344f6

@ignoramous
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#77

Please sign in to comment.