Adjust close behavior

This commit is contained in:
Cole Brown 2018-09-27 19:56:41 -04:00
parent facf31d624
commit 37fa82bce5
1 changed files with 4 additions and 3 deletions

View File

@ -46,10 +46,12 @@ func (c *Client) NewStream(peer []byte, protos []string) (*pb.StreamInfo, io.Rea
return res.GetStreamInfo(), control, nil
}
func (c *Client) closeListener() {
// Close stops the listener socket.
func (c *Client) Close() error {
if c.listener != nil {
c.listener.Close()
return c.listener.Close()
}
return nil
}
func (c *Client) listen(listenPath string) error {
@ -60,7 +62,6 @@ func (c *Client) listen(listenPath string) error {
c.listener = l
go func(c *Client) {
defer c.closeListener()
for {
conn, err := c.listener.Accept()
if err != nil {