Skip to content

Commit

Permalink
Merge pull request #20 from euank/more-close
Browse files Browse the repository at this point in the history
Close listeners in a few more error paths
  • Loading branch information
euank committed May 11, 2019
2 parents 0eaefbf + 37a9485 commit 470cbba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fds.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,14 @@ func (f *Fds) ListenWith(id, network, addr string, listenerFunc func(network, ad
return nil, err
}
if _, ok := ln.(Listener); !ok {
ln.Close()
return nil, errors.Errorf("%T doesn't implement tableroll.Listener", ln)
}
err = f.addListenerLocked(id, network, addr, ln.(Listener))
return ln, err
if err := f.addListenerLocked(id, network, addr, ln.(Listener)); err != nil {
ln.Close()
return nil, err
}
return ln, nil
}

// Listener returns an inherited listener with the given ID, or nil.
Expand Down

0 comments on commit 470cbba

Please sign in to comment.