dont use named return variables in a strange way

This commit is contained in:
Naitik Shah 2013-10-06 11:05:27 -07:00
parent 61aafa98f8
commit 70bbce6ad2

View File

@ -92,11 +92,12 @@ func (l *listener) Close() error {
return err return err
} }
func (l *listener) Accept() (c net.Conn, err error) { func (l *listener) Accept() (net.Conn, error) {
// Presume we'll accept and decrement in defer if we don't. If we did this // Presume we'll accept and decrement in defer if we don't. If we did this
// after a successful accept we would have a race condition where we may end // after a successful accept we would have a race condition where we may end
// up incorrectly shutting down between the time we do a successful accept // up incorrectly shutting down between the time we do a successful accept
// and the increment. // and the increment.
var c net.Conn
l.wg.Add(1) l.wg.Add(1)
defer func() { defer func() {
// If we didn't accept, we decrement our presumptuous count above. // If we didn't accept, we decrement our presumptuous count above.
@ -112,7 +113,7 @@ func (l *listener) Accept() (c net.Conn, err error) {
} }
l.closedMutex.RUnlock() l.closedMutex.RUnlock()
c, err = l.Listener.Accept() c, err := l.Listener.Accept()
if err != nil { if err != nil {
if strings.HasSuffix(err.Error(), errClosed) { if strings.HasSuffix(err.Error(), errClosed) {
return nil, ErrAlreadyClosed return nil, ErrAlreadyClosed