diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nshd/hackers_git/hackers.go | 8 | ||||
-rw-r--r-- | src/nshd/hackers_git/hackers_watch.go | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go index b1fffc6..ecbda7a 100644 --- a/src/nshd/hackers_git/hackers.go +++ b/src/nshd/hackers_git/hackers.go @@ -23,6 +23,7 @@ type Hackers struct { util.NullBackend cfg Config lock sync.RWMutex + workers sync.WaitGroup users map[int32]user passwords map[int32]string @@ -44,11 +45,16 @@ func NewHackers(config Config) *Hackers { if err != nil { return nil } - go o.worker() + o.workers.Add(1) + go func() { + defer o.workers.Done() + o.worker() + }() return &o } func (o *Hackers) Close() { + defer o.workers.Wait() logger.Info("Closing hackers.git session") o.lock.Lock() defer o.lock.Unlock() diff --git a/src/nshd/hackers_git/hackers_watch.go b/src/nshd/hackers_git/hackers_watch.go index 87c856d..9592dab 100644 --- a/src/nshd/hackers_git/hackers_watch.go +++ b/src/nshd/hackers_git/hackers_watch.go @@ -181,9 +181,5 @@ func (o *Hackers) worker() { } } } - // 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") + logger.Info("Stopped hackers.git inotify watcher") } |