From b190157b8c568922f7f9b4039b67a34862fa9f54 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 12 Sep 2015 09:14:40 -0600 Subject: Add an inotify watcher utility using channels; use it. The interface of inotify/inutil.Watcher more resembles golang.org/x/exp/inotify; with it using channels instead of repeated calls to Read(). In my use-case, this is useful because it allows implementing a "read" (select, really) that doesn't block Close(); which is required to handle the TERM signal correctly. --- src/nshd/hackers_git/hackers.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/nshd/hackers_git/hackers.go') diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go index 446351d..f47868f 100644 --- a/src/nshd/hackers_git/hackers.go +++ b/src/nshd/hackers_git/hackers.go @@ -2,11 +2,11 @@ package hackers_git import ( "inotify" + "inotify/inutil" "nslcd_proto" "nslcd_proto/util" "nslcd_systemd" "sd_daemon/logger" - "sd_daemon/lsb" "sync" ) @@ -24,11 +24,12 @@ type Hackers struct { util.NullBackend Cfg Config lock sync.RWMutex + workers sync.WaitGroup users map[int32]user groups map[string]map[string]bool - in_fd *inotify.Inotify + in_fd *inutil.Watcher in_wd_home inotify.Wd in_wd_yaml inotify.Wd in_uid2wd map[int32]inotify.Wd @@ -44,10 +45,6 @@ func (o *Hackers) Init() error { logger.Err("Could not initialize hackers.git: %v", err) return err } - go func() { - defer lsb.Recover() - o.worker() - }() return nil } -- cgit v1.2.3-54-g00ecf