net/dns: updated gonotify dependency to v2 that supports closable context

Signed-off-by: Ilarion Kovalchuk <illarion.kovalchuk@gmail.com>
This commit is contained in:
Ilarion Kovalchuk
2024-08-22 13:40:59 +03:00
committed by Brad Fitzpatrick
parent 696711cc17
commit 0cb7eb9b75
5 changed files with 9 additions and 15 deletions

View File

@@ -7,21 +7,20 @@ import (
"bytes"
"context"
"github.com/illarion/gonotify"
"github.com/illarion/gonotify/v2"
"tailscale.com/health"
)
func (m *directManager) runFileWatcher() {
in, err := gonotify.NewInotify()
ctx, cancel := context.WithCancel(m.ctx)
defer cancel()
in, err := gonotify.NewInotify(ctx)
if err != nil {
// Oh well, we tried. This is all best effort for now, to
// surface warnings to users.
m.logf("dns: inotify new: %v", err)
return
}
ctx, cancel := context.WithCancel(m.ctx)
defer cancel()
go m.closeInotifyOnDone(ctx, in)
const events = gonotify.IN_ATTRIB |
gonotify.IN_CLOSE_WRITE |
@@ -107,8 +106,3 @@ func (m *directManager) checkForFileTrample() {
m.logf("trample: resolv.conf changed from what we expected. did some other program interfere? current contents: %q", show)
m.health.SetUnhealthy(resolvTrampleWarnable, nil)
}
func (m *directManager) closeInotifyOnDone(ctx context.Context, in *gonotify.Inotify) {
<-ctx.Done()
in.Close()
}