summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-09-12 00:24:08 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-09-12 00:24:08 -0600
commit8436272d180b007e265ac2493767d1bfd21914c8 (patch)
tree9f488558e7fdda751f2b36294067c8d63909de56
parent65c805bea141c59f1108265bd36dfef68fbe976e (diff)
hackers_watch: fix double-lock error
-rw-r--r--src/nshd/hackers_git/hackers_watch.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go
index 919a578..c10ec78 100644
--- a/src/nshd/hackers_git/hackers_watch.go
+++ b/src/nshd/hackers_git/hackers_watch.go
@@ -70,7 +70,7 @@ func (o *Hackers) reload() (err error) {
o.in_uid2wd = make(map[int32]inotify.Wd, len(filenames))
o.in_wd2uid = make(map[inotify.Wd]int32, len(filenames))
for _, filename := range filenames {
- o.load_yaml_file(filename)
+ o.load_yaml_file(filename, false)
}
err = nil
@@ -97,14 +97,16 @@ func (o *Hackers) del_user_from_group(username string, groupname string) {
}
}
-func (o *Hackers) load_yaml_file(filename string) {
+func (o *Hackers) load_yaml_file(filename string, uselock bool) {
logger.Debug("hackers.git: Loading YAML file: %s", filename)
user, err := parse_user_yaml(filename)
uid := user.passwd.UID
if err == nil {
logger.Debug("hackers.git: -> User %d added/updated", uid)
- o.lock.Lock()
- defer o.lock.Unlock()
+ if uselock {
+ o.lock.Lock()
+ defer o.lock.Unlock()
+ }
if olduser, found := o.users[uid]; found {
for _, groupname := range olduser.groups {
o.del_user_from_group(olduser.passwd.Name, groupname)
@@ -118,8 +120,10 @@ func (o *Hackers) load_yaml_file(filename string) {
} else if uid >= 0 {
// User became invalid
logger.Debug("hackers.git: -> User %d invalidated: %v", uid, err)
- o.lock.Lock()
- defer o.lock.Unlock()
+ if uselock {
+ o.lock.Lock()
+ defer o.lock.Unlock()
+ }
if wd, found := o.in_uid2wd[uid]; found {
o.unwatchHomedir(wd)
}