fix: quicStreamPacketConn's close
This commit is contained in:
parent
17c081a40c
commit
0da09c5ddd
1 changed files with 2 additions and 9 deletions
|
@ -401,7 +401,6 @@ func (t *Client) ListenPacketContext(ctx context.Context, metadata *C.Metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe1, pipe2 := net.Pipe()
|
pipe1, pipe2 := net.Pipe()
|
||||||
inputCh := make(chan udpData)
|
|
||||||
var connId uint32
|
var connId uint32
|
||||||
for {
|
for {
|
||||||
connId = rand.Uint32()
|
connId = rand.Uint32()
|
||||||
|
@ -416,24 +415,16 @@ func (t *Client) ListenPacketContext(ctx context.Context, metadata *C.Metadata)
|
||||||
lAddr: quicConn.LocalAddr(),
|
lAddr: quicConn.LocalAddr(),
|
||||||
client: t,
|
client: t,
|
||||||
inputConn: N.NewBufferedConn(pipe2),
|
inputConn: N.NewBufferedConn(pipe2),
|
||||||
inputCh: inputCh,
|
|
||||||
}
|
}
|
||||||
return pc, nil
|
return pc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type udpData struct {
|
|
||||||
data []byte
|
|
||||||
addr net.Addr
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
type quicStreamPacketConn struct {
|
type quicStreamPacketConn struct {
|
||||||
connId uint32
|
connId uint32
|
||||||
quicConn quic.Connection
|
quicConn quic.Connection
|
||||||
lAddr net.Addr
|
lAddr net.Addr
|
||||||
client *Client
|
client *Client
|
||||||
inputConn *N.BufferedConn
|
inputConn *N.BufferedConn
|
||||||
inputCh chan udpData
|
|
||||||
|
|
||||||
closeOnce sync.Once
|
closeOnce sync.Once
|
||||||
closeErr error
|
closeErr error
|
||||||
|
@ -455,6 +446,8 @@ func (q *quicStreamPacketConn) close() (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
q.client.deferQuicConn(q.quicConn, err)
|
q.client.deferQuicConn(q.quicConn, err)
|
||||||
}()
|
}()
|
||||||
|
q.client.udpInputMap.Delete(q.connId)
|
||||||
|
_ = q.inputConn.Close()
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
err = NewDissociate(q.connId).WriteTo(buf)
|
err = NewDissociate(q.connId).WriteTo(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue