Changeset 253 in code for trunk/user.go
- Timestamp:
- Apr 10, 2020, 5:22:47 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user.go
r252 r253 46 46 } 47 47 48 type networkHistory struct { 49 offlineClients map[string]uint64 // indexed by client name 50 ring *Ring // can be nil if there are no offline clients 51 } 52 48 53 type network struct { 49 54 Network 50 55 user *user 51 ring *Ring52 56 stopped chan struct{} 53 57 54 conn *upstreamConn 55 history map[string]uint64 56 lastError error 58 conn *upstreamConn 59 history map[string]*networkHistory // indexed by entity 60 offlineClients map[string]struct{} // indexed by client name 61 lastError error 57 62 } 58 63 59 64 func newNetwork(user *user, record *Network) *network { 60 65 return &network{ 61 Network: *record,62 user: user,63 ring: NewRing(user.srv.RingCap),64 stopped: make(chan struct{}),65 history: make(map[string]uint64),66 Network: *record, 67 user: user, 68 stopped: make(chan struct{}), 69 history: make(map[string]*networkHistory), 70 offlineClients: make(map[string]struct{}), 66 71 } 67 72 } … … 295 300 dc := e.dc 296 301 297 dc.forEachNetwork(func(net *network) {298 seq := net.ring.Cur()299 net.history[dc.clientName] = seq300 })301 302 302 for i := range u.downstreamConns { 303 303 if u.downstreamConns[i] == dc { … … 306 306 } 307 307 } 308 309 // Save history if we're the last client with this name 310 skipHistory := make(map[*network]bool) 311 u.forEachDownstream(func(conn *downstreamConn) { 312 if dc.clientName == conn.clientName { 313 skipHistory[conn.network] = true 314 } 315 }) 316 317 dc.forEachNetwork(func(net *network) { 318 if skipHistory[net] || skipHistory[nil] { 319 return 320 } 321 322 net.offlineClients[dc.clientName] = struct{}{} 323 for _, history := range net.history { 324 history.offlineClients[dc.clientName] = history.ring.Cur() 325 } 326 }) 308 327 309 328 u.forEachUpstream(func(uc *upstreamConn) {
Note:
See TracChangeset
for help on using the changeset viewer.