mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 01:57:02 +00:00
Handle EOFs different from other net io errors
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
"github.com/jhillyerd/inbucket/log"
|
||||
"io"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -160,6 +161,17 @@ func (s *Server) startSession(id int, conn net.Conn) {
|
||||
}
|
||||
} else {
|
||||
// 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)
|
||||
if netErr, ok := err.(net.Error); ok {
|
||||
if netErr.Timeout() {
|
||||
|
||||
Reference in New Issue
Block a user