summaryrefslogtreecommitdiffstats
path: root/lib/syncthing/stEvent.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-24 21:45:32 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-24 21:45:32 +0200
commit3f0a0e6f9cf9e5963d89c6d1be515d8f43ee08bb (patch)
tree33d8915b02b7146b4898ae1cdd595db14e9ec3b7 /lib/syncthing/stEvent.go
parent347bd1674bbf67ccb6209951a4bf8f2971715532 (diff)
Take care of ST connection lost in ST event monitor.
Diffstat (limited to 'lib/syncthing/stEvent.go')
-rw-r--r--lib/syncthing/stEvent.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/syncthing/stEvent.go b/lib/syncthing/stEvent.go
index bf2a809..9ca8b78 100644
--- a/lib/syncthing/stEvent.go
+++ b/lib/syncthing/stEvent.go
@@ -148,6 +148,8 @@ func (e *Events) getEvents(since int) ([]STEvent, error) {
func (e *Events) monitorLoop() {
e.log.Infof("Event monitoring running...")
since := 0
+ cntErrConn := 0
+ cntErrRetry := 1
for {
select {
case <-e.stop:
@@ -155,11 +157,32 @@ func (e *Events) monitorLoop() {
return
case <-time.After(e.MonitorTime * time.Millisecond):
+
+ if !e.st.Connected {
+ cntErrConn++
+ time.Sleep(time.Second)
+ if cntErrConn > cntErrRetry {
+ e.log.Error("ST Event monitor: ST connection down")
+ cntErrConn = 0
+ cntErrRetry *= 2
+ if _, err := e.getEvents(since); err == nil {
+ e.st.Connected = true
+ cntErrRetry = 1
+ // XXX - should we reset since value ?
+ goto readEvent
+ }
+ }
+ continue
+ }
+
+ readEvent:
stEvArr, err := e.getEvents(since)
if err != nil {
e.log.Errorf("Syncthing Get Events: %v", err)
+ e.st.Connected = false
continue
}
+
// Process events
for _, stEv := range stEvArr {
since = stEv.SubscriptionID