Skip to content

Commit de349a7

Browse files
author
Shlomi Noach
authored
Merge pull request #401 from github/sock-nil-connection
error and nil checks on socket connection
2 parents 3313cb3 + 3092e9c commit de349a7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

go/logic/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ func (this *Server) Serve() (err error) {
9898
}
9999

100100
func (this *Server) handleConnection(conn net.Conn) (err error) {
101-
defer conn.Close()
101+
if conn != nil {
102+
defer conn.Close()
103+
}
102104
command, _, err := bufio.NewReader(conn).ReadLine()
105+
if err != nil {
106+
return err
107+
}
103108
return this.onServerCommand(string(command), bufio.NewWriter(conn))
104109
}
105110

0 commit comments

Comments
 (0)