mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 10:07:02 +00:00
Handle EOFs different from other net io errors
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"container/list"
|
"container/list"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jhillyerd/inbucket/log"
|
"github.com/jhillyerd/inbucket/log"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -160,6 +161,17 @@ func (s *Server) startSession(id int, conn net.Conn) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// readLine() returned an error
|
// readLine() returned an error
|
||||||
|
if err == io.EOF {
|
||||||
|
switch ss.state {
|
||||||
|
case GREET, READY:
|
||||||
|
// EOF is common here
|
||||||
|
ss.info("Client closed connection (state %v)", ss.state)
|
||||||
|
default:
|
||||||
|
ss.warn("Got EOF while in state %v", ss.state)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// not an EOF
|
||||||
ss.warn("Connection error: %v", err)
|
ss.warn("Connection error: %v", err)
|
||||||
if netErr, ok := err.(net.Error); ok {
|
if netErr, ok := err.(net.Error); ok {
|
||||||
if netErr.Timeout() {
|
if netErr.Timeout() {
|
||||||
|
|||||||
Reference in New Issue
Block a user