git » chasquid » commit c8fbf2e

smtpsrv: Don't consider client EOF an error

author Alberto Bertogli
2020-03-21 16:58:56 UTC
committer Alberto Bertogli
2020-03-21 16:58:56 UTC
parent fcbd20cd74a18014fed42d9d72dacc0d1fabd36c

smtpsrv: Don't consider client EOF an error

When the client closes the connection, which is very common, chasquid
logs it as an error ("exiting with error: EOF").

That can be confusing and mislead users, and also makes a lot of
traces be marked as errored, when nothing wrong occurred.

So this patch changes the log to not treat it as an error.

internal/smtpsrv/conn.go +5 -1

diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go
index f051012..0568581 100644
--- a/internal/smtpsrv/conn.go
+++ b/internal/smtpsrv/conn.go
@@ -280,7 +280,11 @@ loop:
 	}
 
 	if err != nil {
-		c.tr.Errorf("exiting with error: %v", err)
+		if err == io.EOF {
+			c.tr.Debugf("client closed the connection")
+		} else {
+			c.tr.Errorf("exiting with error: %v", err)
+		}
 	}
 }