mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Fix closing quic connections
This commit is contained in:
parent
3f56f5f5d3
commit
b18f615c66
1 changed files with 15 additions and 0 deletions
|
@ -78,11 +78,26 @@ func (q *quicMultiConn) Close() error {
|
|||
return q.Connection.CloseWithError(2, "")
|
||||
}
|
||||
|
||||
const (
|
||||
reset quic.StreamErrorCode = 0
|
||||
)
|
||||
|
||||
type quicNetConn struct {
|
||||
quic.Stream
|
||||
localAddr, remoteAddr net.Addr
|
||||
}
|
||||
|
||||
func (q quicNetConn) Close() error {
|
||||
// From quic docs: https://quic-go.net/docs/quic/streams/
|
||||
// "Calling Close on a quic.Stream closes the send side of the stream.
|
||||
// Note that for bidirectional streams, Close only closes the send side of the stream.
|
||||
// It is still possible to read from the stream until the peer closes or resets the stream."
|
||||
//
|
||||
// That's why we cancel read explicitly (same approach used in libp2p)
|
||||
q.Stream.CancelRead(reset)
|
||||
return q.Stream.Close()
|
||||
}
|
||||
|
||||
func (q quicNetConn) LocalAddr() net.Addr {
|
||||
return q.localAddr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue