From 3c4b49aed2451c4ae4c3e1273d920016ed646df6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 5 Sep 2017 14:52:27 -0400 Subject: nslcd_systemd: Don't spew errors about "closed network socket" while stopping --- nslcd_systemd/nslcd_systemd.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'nslcd_systemd') diff --git a/nslcd_systemd/nslcd_systemd.go b/nslcd_systemd/nslcd_systemd.go index a828ac5..2839af4 100644 --- a/nslcd_systemd/nslcd_systemd.go +++ b/nslcd_systemd/nslcd_systemd.go @@ -103,6 +103,7 @@ func handler(conn *net.UnixConn, backend nslcd_server.Backend) { } func Main(backend Backend) uint8 { + defer sd_daemon.Recover() var err error = nil sigs := make(chan os.Signal) @@ -127,7 +128,7 @@ func Main(backend Backend) uint8 { sd_daemon.Notification{State: "STOPPING=1"}.Send(false) return sd_daemon.EXIT_NOTRUNNING } - defer socket.Close() + defer func() { socket.(*net.UnixListener).SetDeadline(time.Now()) }() sock := make(chan *net.UnixConn) socket_error := make(chan error) wg.Add(1) @@ -139,7 +140,9 @@ func Main(backend Backend) uint8 { for !last { conn, err := socket.Accept() if err != nil { - if ne, ok := err.(net.Error); ok && ne.Temporary() { + if ne, ok := err.(net.Error); ok && ne.Timeout() { + last = true + } else if ne, ok := err.(net.Error); ok && ne.Temporary() { sd_daemon.Log.Notice(fmt.Sprintf("%v", err)) } else { socket_error <- err -- cgit v1.2.3-2-g168b