summaryrefslogtreecommitdiff
path: root/nslcd_systemd
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-09-05 14:52:27 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-09-08 16:55:55 -0400
commit3c4b49aed2451c4ae4c3e1273d920016ed646df6 (patch)
treea9c7ffb26ea382fe4005bb2aec872da2b8103c84 /nslcd_systemd
parent641ef9d6c7f1abf2ec824dc771fa474bd38f429d (diff)
nslcd_systemd: Don't spew errors about "closed network socket" while stopping
Diffstat (limited to 'nslcd_systemd')
-rw-r--r--nslcd_systemd/nslcd_systemd.go7
1 files changed, 5 insertions, 2 deletions
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