run runs the synchronisation server, which is responsible for queueing heartbeat notifications and removing expired synchronisation sessions.
()
| 311 | // run runs the synchronisation server, which is responsible for queueing |
| 312 | // heartbeat notifications and removing expired synchronisation sessions. |
| 313 | func (s *syncServer) run() { |
| 314 | for now := range time.Tick(s.heartbeatInterval) { |
| 315 | s.sessionLock.Lock() |
| 316 | for id, ss := range s.sessions { |
| 317 | ss.RLock() |
| 318 | expiry := ss.expiryTime |
| 319 | ss.RUnlock() |
| 320 | if now.After(expiry) { |
| 321 | log.Warningf("Sync session %d with %v has expired", id, ss.node) |
| 322 | delete(s.sessions, id) |
| 323 | continue |
| 324 | } |
| 325 | ss.addNote(&SyncNote{Type: SNTHeartbeat, Time: now}) |
| 326 | } |
| 327 | s.sessionLock.Unlock() |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | // syncClient contains the data needed by a synchronisation client. |
| 332 | type syncClient struct { |