summaryrefslogtreecommitdiff
path: root/nslcd_systemd/nslcd_systemd.go
diff options
context:
space:
mode:
Diffstat (limited to 'nslcd_systemd/nslcd_systemd.go')
-rw-r--r--nslcd_systemd/nslcd_systemd.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/nslcd_systemd/nslcd_systemd.go b/nslcd_systemd/nslcd_systemd.go
index 2839af4..0856b70 100644
--- a/nslcd_systemd/nslcd_systemd.go
+++ b/nslcd_systemd/nslcd_systemd.go
@@ -38,6 +38,7 @@ import (
"os"
"os/signal"
"sync"
+ "time"
"git.lukeshu.com/go/libnslcd/nslcd_server"
"git.lukeshu.com/go/libsystemd/sd_daemon"
@@ -136,6 +137,7 @@ func Main(backend Backend) uint8 {
defer sd_daemon.Recover()
defer wg.Done()
+ var tempDelay time.Duration
last := false
for !last {
conn, err := socket.Accept()
@@ -144,6 +146,15 @@ func Main(backend Backend) uint8 {
last = true
} else if ne, ok := err.(net.Error); ok && ne.Temporary() {
sd_daemon.Log.Notice(fmt.Sprintf("%v", err))
+ if tempDelay == 0 {
+ tempDelay = 5 * time.Millisecond
+ } else {
+ tempDelay *= 2
+ }
+ if max := 1 * time.Second; tempDelay > max {
+ tempDelay = max
+ }
+ time.Sleep(tempDelay)
} else {
socket_error <- err
last = true