Merge pull request #2 from crosbymichael/abort-on-EINVAL

Only abort Accept loop on EINVAL
This commit is contained in:
Andrey Petrov 2014-12-12 23:16:42 -08:00
commit 1170c89335

View File

@ -7,6 +7,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"sync" "sync"
"syscall"
"time" "time"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
@ -222,13 +223,16 @@ func (s *Server) Start(laddr string) error {
logger.Infof("Listening on %s", laddr) logger.Infof("Listening on %s", laddr)
go func() { go func() {
defer socket.Close()
for { for {
conn, err := socket.Accept() conn, err := socket.Accept()
if err != nil { if err != nil {
// TODO: Handle shutdown more gracefully? logger.Errorf("Failed to accept connection: %v", err)
logger.Errorf("Failed to accept connection, aborting loop: %v", err) if err == syscall.EINVAL {
return // TODO: Handle shutdown more gracefully?
return
}
} }
// Goroutineify to resume accepting sockets early. // Goroutineify to resume accepting sockets early.