MCPcopy
hub / github.com/cbeuw/Cloak / updateUsageQueue

Method updateUsageQueue

internal/server/userpanel.go:118–138  ·  view source on GitHub ↗

updateUsageQueue zeroes the accumulated usage all ActiveUsers valve and put the usage data im usageUpdateQueue

()

Source from the content-addressed store, hash-verified

116
117// updateUsageQueue zeroes the accumulated usage all ActiveUsers valve and put the usage data im usageUpdateQueue
118func (panel *userPanel) updateUsageQueue() {
119 panel.activeUsersM.Lock()
120 panel.usageUpdateQueueM.Lock()
121 for _, user := range panel.activeUsers {
122 if user.bypass {
123 continue
124 }
125
126 upIncured, downIncured := user.valve.Nullify()
127 if usage, ok := panel.usageUpdateQueue[user.arrUID]; ok {
128 atomic.AddInt64(usage.up, upIncured)
129 atomic.AddInt64(usage.down, downIncured)
130 } else {
131 // if the user hasn't been added to the queue
132 usage = &usagePair{&upIncured, &downIncured}
133 panel.usageUpdateQueue[user.arrUID] = usage
134 }
135 }
136 panel.activeUsersM.Unlock()
137 panel.usageUpdateQueueM.Unlock()
138}
139
140// updateUsageQueueForOne is the same as updateUsageQueue except it only updates one user's usage
141// this is useful when the user is being terminated

Callers 3

regularQueueUploadMethod · 0.95
TestUserPanel_BypassUserFunction · 0.80

Calls 1

NullifyMethod · 0.65

Tested by 2

TestUserPanel_BypassUserFunction · 0.64