Skip to content

Commit

Permalink
upstream: add more
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jan 26, 2024
1 parent ba9fb97 commit 8f9f9a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions upstream/quic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@ func (q *quicConnTracer) SentLongHeaderPacket(
}

func TestDNSOverQUIC_closingConns(t *testing.T) {
t.Skip("TODO(e.burkov): !! remove skip")

addrPort := startDoQServer(t, 0)

upsURL := (&url.URL{
Expand Down
21 changes: 13 additions & 8 deletions upstream/quicconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,17 @@ func (qc *quicConnector) reset() {
// get returns the connection. If the connection is not established yet, it
// will be established. If the connection establishment fails, the next call
// to get will try to establish the connection again.
func (qc *quicConnector) get() (c quic.Connection, err error) {
func (qc *quicConnector) get() (conn quic.Connection, err error) {
select {
case <-qc.openCh:
qc.mu.Lock()
defer qc.mu.Unlock()

if qc.res != nil {
qc.connHandler.closeConn(qc.res, qc.err)
}

qc.res, qc.err = qc.connHandler.openConnection()
qc.resetCh <- struct{}{}
qc.reopen()
if qc.err != nil {
qc.reset()
qc.openCh <- struct{}{}
} else {
qc.resetCh <- struct{}{}
}
default:
qc.mu.RLock()
Expand All @@ -71,3 +68,11 @@ func (qc *quicConnector) get() (c quic.Connection, err error) {

return qc.res, qc.err
}

func (qc *quicConnector) reopen() {
if qc.res != nil {
qc.connHandler.closeConn(qc.res, qc.err)
}

qc.res, qc.err = qc.connHandler.openConnection()
}

0 comments on commit 8f9f9a4

Please sign in to comment.