summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-03 13:50:53 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-03 13:53:13 -0600
commit70623707fd76465c7d03fced48bfa14454ef9e09 (patch)
tree3c4e48a14fe2c6d82f3f5f778c40a283e84bdd4e /src
parent2d45bbd332bf439f483dacadf5e3e9776c97ef60 (diff)
fix bugs in code calling inotify
Diffstat (limited to 'src')
-rw-r--r--src/nshd/hackers_git/hackers_watch.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index 99e5eb3..87c856d 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -46,7 +46,6 @@ func (o *Hackers) unwatchHomedir(wd inotify.Cint) {
func (o *Hackers) close() {
if o.in_fd != nil {
o.in_fd.Close()
- o.in_fd = nil
}
o.in_wd_home = -1
o.in_wd_yaml = -1
@@ -140,6 +139,9 @@ func (o *Hackers) worker() {
worker_error("failed to load %q: %v", o.cfg.Yamldir, err)
}
} else if event.Mask&in_CHILD_ANY != 0 {
+ if (event.Name == nil) {
+ panic("recieved child event from inotify, but no child name")
+ }
filename := o.cfg.Yamldir + "/" + *event.Name
logger.Info("Loading yaml file: %s", filename)
user, err := load_user_yaml(filename)
@@ -170,10 +172,18 @@ func (o *Hackers) worker() {
if event.Mask&in_DIR_INVALID != 0 {
o.unwatchHomedir(event.Wd)
o.worker_watch_homedirs()
- } else if *event.Name == ".password" {
- o.worker_handle_passwd(o.in_wd2uid[event.Wd])
+ } else if event.Name != nil {
+ if *event.Name == ".password" {
+ o.worker_handle_passwd(o.in_wd2uid[event.Wd])
+ }
+ } else {
+ logger.Debug("event didn't match: %#v", event)
}
}
}
- panic("not reached")
+ // This happens only sometimes--depending on if the main
+ // goroutine or this goroutine is killed by os.Exit first;
+ // this happens if the main goroutine calls inotify.Close()
+ // before this groutine is killed.
+ logger.Info("Stopping hackers.git inotify watcher")
}