Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
simplify accepting new connections
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Oct 27, 2017
1 parent b2606fa commit 1820ac9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package conn

import (
"context"
"errors"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -91,13 +90,11 @@ func (l *listener) Accept() (iconn.Conn, error) {
log.Warningf("listener %s listening INSECURELY!", l)
}

for c := range l.incoming {
if c.err != nil {
return nil, c.err
}
return c.conn, nil
c, ok := <-l.incoming
if !ok {
return nil, fmt.Errorf("listener is closed")
}
return nil, errors.New("listener is closed")
return c.conn, c.err
}

func (l *listener) Addr() net.Addr {
Expand Down

0 comments on commit 1820ac9

Please sign in to comment.