Pull request: 5089-windows-hosts-crash
Updates #5089. Squashed commit of the following: commit dd3ce763326ad3207de111bb911e0a2665bcebba Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 7 16:21:43 2022 +0300 aghnet: fix comparison commit 0d736fb7fc5cb2e77fd533cd95fdf3fbc6dc86d1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 7 14:13:05 2022 +0300 aghnet: fix crash
This commit is contained in:
@@ -139,6 +139,8 @@ type HostsRecord struct {
|
||||
func (rec *HostsRecord) equal(other *HostsRecord) (ok bool) {
|
||||
if rec == nil {
|
||||
return other == nil
|
||||
} else if other == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return rec.Canonical == other.Canonical && rec.Aliases.Equal(other.Aliases)
|
||||
@@ -478,7 +480,11 @@ func (hc *HostsContainer) refresh() (err error) {
|
||||
return fmt.Errorf("refreshing : %w", err)
|
||||
}
|
||||
|
||||
if maps.EqualFunc(hp.table, hc.last, (*HostsRecord).equal) {
|
||||
// hc.last is nil on the first refresh, so let that one through.
|
||||
//
|
||||
// TODO(a.garipov): Once https://github.com/golang/go/issues/56621 is
|
||||
// resolved, remove the first condition.
|
||||
if hc.last != nil && maps.EqualFunc(hp.table, hc.last, (*HostsRecord).equal) {
|
||||
log.Debug("%s: no changes detected", hostsContainerPref)
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user