Fix shutdown race in startSSFUnix
The order of `defer` statements in this function's work goroutine was
inverted (defers are a stack!). To avoid any confusion about what
happens when, let's just put the deferred statements in a function and
run them in the order they're meant to be run.
@@ -160,8 +160,10 @@ func startSSFUnix(s *Server, addr *net.UnixAddr) <-chan struct{} {
go func() {
conns := make(chan net.Conn)
go func() {
- defer lock.Unlock()
- defer close(done)
+ defer func() {
+ lock.Unlock()
+ close(done)
+ }()
for {
conn, err := listener.AcceptUnix()
if err != nil {
