summaryrefslogtreecommitdiff
path: root/nslcd_systemd
diff options
context:
space:
mode:
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