Commit c7e337c9 authored by ale's avatar ale
Browse files

Improve error handling in UNIX socket server

Log errors, and drop unnecessary replies when shutting down a
connection.
parent f4a6a804
......@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io"
"log"
"net"
......@@ -159,11 +160,11 @@ func (s *SocketServer) handle(nc net.Conn) {
return
case nargs == 2 && cmd == "auth":
if err := s.handleAuth(c, parts[1]); err != nil {
log.Printf("error from %s: %v", nc.RemoteAddr(), err)
log.Printf("error in auth: %v", err)
return
}
default:
c.PrintfLine("syntax error from %s", nc.RemoteAddr())
log.Printf("syntax error")
return
}
}
......@@ -172,8 +173,7 @@ func (s *SocketServer) handle(nc net.Conn) {
func (s *SocketServer) handleAuth(c *textproto.Conn, line []byte) error {
var req auth.Request
if err := s.codec.Decode(line, &req); err != nil {
c.PrintfLine("syntax error")
return errors.New("syntax error")
return fmt.Errorf("decoding error: %v", err)
}
// Set a timeout for the request.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment