Use defer for closing the listenmutex
This commit is contained in:
parent
7e7f06b31f
commit
2c1c81aecd
1 changed files with 2 additions and 1 deletions
3
sshd.go
3
sshd.go
|
|
@ -180,18 +180,19 @@ func main() {
|
|||
go func() {
|
||||
err := client.SshConn.Wait()
|
||||
client.ListenMutex.Lock()
|
||||
defer client.ListenMutex.Unlock()
|
||||
client.Stopping = true
|
||||
|
||||
if *verbose {
|
||||
log.Printf("[%s] SSH connection closed: %s", client.Name, err)
|
||||
}
|
||||
|
||||
for bind, listener := range client.Listeners {
|
||||
if *verbose {
|
||||
log.Printf("[%s] Closing listener bound to %s", client.Name, bind)
|
||||
}
|
||||
listener.Close()
|
||||
}
|
||||
client.ListenMutex.Unlock()
|
||||
}()
|
||||
|
||||
// Accept requests & channels
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue