Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
Close the connection on the server when the client closes it first
Browse files Browse the repository at this point in the history
When the client closes the connection, the server will read EOF. In that case the connection should be closed on the server as well. Without this change the server goroutine will go into an infinite loop when the client closes the connection. It'll try to read, get an EOF, then "continue", go back to read, get another EOF and so on. That takes 100% CPU in this situation.
  • Loading branch information
folbricht committed Apr 20, 2016
1 parent 60c0b22 commit be440d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (conn *Conn) Serve() {
line, err := conn.controlReader.ReadString('\n')
if err != nil {
if err == io.EOF {
continue
break
}

conn.logger.Print(fmt.Sprintln("read error:", err))
Expand Down

0 comments on commit be440d6

Please sign in to comment.