mirror of
https://github.com/safing/portmaster
synced 2025-09-02 10:39:22 +00:00
Fix panic in new tcp based dns resolver
Use service worker in order to survive future panics better
This commit is contained in:
parent
2afd9cd143
commit
96fcc6993c
1 changed files with 18 additions and 6 deletions
|
@ -102,7 +102,9 @@ connMgmt:
|
||||||
if tr.dnsConnection != nil {
|
if tr.dnsConnection != nil {
|
||||||
connClosing.Set()
|
connClosing.Set()
|
||||||
_ = tr.dnsConnection.Close()
|
_ = tr.dnsConnection.Close()
|
||||||
|
if cancelConnCtx != nil {
|
||||||
cancelConnCtx()
|
cancelConnCtx()
|
||||||
|
}
|
||||||
|
|
||||||
tr.dnsConnection = nil
|
tr.dnsConnection = nil
|
||||||
atomic.AddUint32(tr.connInstanceID, 1)
|
atomic.AddUint32(tr.connInstanceID, 1)
|
||||||
|
@ -120,9 +122,15 @@ connMgmt:
|
||||||
tr.Unlock()
|
tr.Unlock()
|
||||||
|
|
||||||
// hint network environment at failed connection
|
// hint network environment at failed connection
|
||||||
|
if failCnt >= FailThreshold {
|
||||||
netenv.ReportFailedConnection()
|
netenv.ReportFailedConnection()
|
||||||
|
}
|
||||||
|
|
||||||
|
// The linter said so. Don't even...
|
||||||
|
if cancelConnCtx != nil {
|
||||||
|
cancelConnCtx()
|
||||||
|
}
|
||||||
|
|
||||||
cancelConnCtx() // The linter said so. Don't even...
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +217,9 @@ connMgmt:
|
||||||
msg, err := conn.ReadMsg()
|
msg, err := conn.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if connClosing.SetToIf(false, true) {
|
if connClosing.SetToIf(false, true) {
|
||||||
|
if cancelConnCtx != nil {
|
||||||
cancelConnCtx()
|
cancelConnCtx()
|
||||||
|
}
|
||||||
tr.ReportFailure()
|
tr.ReportFailure()
|
||||||
failCnt++
|
failCnt++
|
||||||
if tr.IsFailing() {
|
if tr.IsFailing() {
|
||||||
|
@ -249,7 +259,9 @@ connMgmt:
|
||||||
err := tr.dnsConnection.WriteMsg(msg)
|
err := tr.dnsConnection.WriteMsg(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if connClosing.SetToIf(false, true) {
|
if connClosing.SetToIf(false, true) {
|
||||||
|
if cancelConnCtx != nil {
|
||||||
cancelConnCtx()
|
cancelConnCtx()
|
||||||
|
}
|
||||||
tr.ReportFailure()
|
tr.ReportFailure()
|
||||||
failCnt++
|
failCnt++
|
||||||
if tr.IsFailing() {
|
if tr.IsFailing() {
|
||||||
|
@ -344,7 +356,7 @@ func (tr *TCPResolver) submitQuery(_ context.Context, q *Query) *InFlightQuery {
|
||||||
|
|
||||||
// make sure client is started
|
// make sure client is started
|
||||||
if tr.clientStarted.SetToIf(false, true) {
|
if tr.clientStarted.SetToIf(false, true) {
|
||||||
module.StartWorker("dns client", tr.client)
|
module.StartServiceWorker("dns client", 10*time.Millisecond, tr.client)
|
||||||
}
|
}
|
||||||
|
|
||||||
return inFlight
|
return inFlight
|
||||||
|
|
Loading…
Add table
Reference in a new issue