mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-05-31 07:39:24 +03:00
Merge pull request #2 from crosbymichael/abort-on-EINVAL
Only abort Accept loop on EINVAL
This commit is contained in:
commit
1170c89335
10
server.go
10
server.go
@ -7,6 +7,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
@ -222,13 +223,16 @@ func (s *Server) Start(laddr string) error {
|
||||
logger.Infof("Listening on %s", laddr)
|
||||
|
||||
go func() {
|
||||
defer socket.Close()
|
||||
for {
|
||||
conn, err := socket.Accept()
|
||||
|
||||
if err != nil {
|
||||
// TODO: Handle shutdown more gracefully?
|
||||
logger.Errorf("Failed to accept connection, aborting loop: %v", err)
|
||||
return
|
||||
logger.Errorf("Failed to accept connection: %v", err)
|
||||
if err == syscall.EINVAL {
|
||||
// TODO: Handle shutdown more gracefully?
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Goroutineify to resume accepting sockets early.
|
||||
|
Loading…
x
Reference in New Issue
Block a user