From 81423a0b6182adbbde41dfeef16201e36ed69d04 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Wed, 24 Oct 2012 13:07:07 -0700 Subject: [PATCH] Handle EOFs different from other net io errors --- smtpd/handler.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smtpd/handler.go b/smtpd/handler.go index 85c46f9..d09c305 100644 --- a/smtpd/handler.go +++ b/smtpd/handler.go @@ -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() {