Skip to content

Commit

Permalink
Pull request: proxy: fix tcp conn loop
Browse files Browse the repository at this point in the history
Updates AdguardTeam/AdGuardHome#4042.

Squashed commit of the following:

commit 42f92b4
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Dec 29 21:56:42 2021 +0300

    proxy: fix logs

commit a5b56fa
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Dec 29 21:54:21 2021 +0300

    proxy: fix tcp conn loop
  • Loading branch information
ainar-g committed Dec 29, 2021
1 parent 135a114 commit 3df4133
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions proxy/server_quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (p *Proxy) quicPacketLoop(l quic.Listener, requestGoroutinesSema semaphore)
} else {
log.Info("got error when reading from QUIC listen: %s", err)
}

break
} else {
requestGoroutinesSema.acquire()
Expand Down Expand Up @@ -86,8 +87,10 @@ func (p *Proxy) handleQUICSession(session quic.Session, requestGoroutinesSema se
} else {
log.Info("got error when accepting a new QUIC stream: %s", err)
}

// Close the session to make sure resources are freed
_ = session.CloseWithError(0, "")

return
}

Expand Down
10 changes: 5 additions & 5 deletions proxy/server_tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (p *Proxy) tcpPacketLoop(l net.Listener, proto Proto, requestGoroutinesSema

if err != nil {
if errors.Is(err, net.ErrClosed) {
log.Debug("tcpPacketLoop: connection closed")
log.Debug("tcpPacketLoop: connection closed: %s", err)
} else {
log.Info("got error when reading from TCP listen: %s", err)
}
Expand Down Expand Up @@ -98,12 +98,12 @@ func (p *Proxy) handleTCPConnection(conn net.Conn, proto Proto) {
packet, err := proxyutil.ReadPrefixed(conn)
if err != nil {
if errors.Is(err, io.EOF) || errors.Is(err, net.ErrClosed) {
continue
log.Debug("handling tcp: connection closed: %s", err)
} else {
log.Error("handling tcp: reading msg: %s", err)
}

log.Error("handling tcp: reading msg: %s", err)

return
break
}

req := &dns.Msg{}
Expand Down

0 comments on commit 3df4133

Please sign in to comment.