mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-25 20:18:31 +00:00
Rename a few variables
This commit is contained in:
parent
d518759fa0
commit
aa6f090fcc
1 changed files with 13 additions and 13 deletions
|
@ -365,7 +365,7 @@ func BunchedRequestFromCM(msg *ClientMessage) BunchedRequest {
|
||||||
return BunchedRequest{Command: msg.Command, Param: msg.origArguments}
|
return BunchedRequest{Command: msg.Command, Param: msg.origArguments}
|
||||||
}
|
}
|
||||||
|
|
||||||
type BunchedResponse struct {
|
type CachedBunchedResponse struct {
|
||||||
Response string
|
Response string
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
}
|
}
|
||||||
|
@ -388,9 +388,9 @@ const (
|
||||||
|
|
||||||
var PendingBunchedRequests map[BunchedRequest]*BunchSubscriberList = make(map[BunchedRequest]*BunchSubscriberList)
|
var PendingBunchedRequests map[BunchedRequest]*BunchSubscriberList = make(map[BunchedRequest]*BunchSubscriberList)
|
||||||
var PendingBunchLock sync.Mutex
|
var PendingBunchLock sync.Mutex
|
||||||
var CachedBunchedRequests map[BunchedRequest]BunchedResponse = make(map[BunchedRequest]BunchedResponse)
|
var BunchCache map[BunchedRequest]CachedBunchedResponse = make(map[BunchedRequest]CachedBunchedResponse)
|
||||||
var CachedBunchLock sync.RWMutex
|
var BunchCacheLock sync.RWMutex
|
||||||
var BunchCacheCleanupSignal *sync.Cond = sync.NewCond(&CachedBunchLock)
|
var BunchCacheCleanupSignal *sync.Cond = sync.NewCond(&BunchCacheLock)
|
||||||
var BunchCacheLastCleanup time.Time
|
var BunchCacheLastCleanup time.Time
|
||||||
|
|
||||||
func bunchCacheJanitor() {
|
func bunchCacheJanitor() {
|
||||||
|
@ -401,7 +401,7 @@ func bunchCacheJanitor() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
CachedBunchLock.Lock()
|
BunchCacheLock.Lock()
|
||||||
for {
|
for {
|
||||||
// Unlocks CachedBunchLock, waits for signal, re-locks
|
// Unlocks CachedBunchLock, waits for signal, re-locks
|
||||||
BunchCacheCleanupSignal.Wait()
|
BunchCacheCleanupSignal.Wait()
|
||||||
|
@ -413,9 +413,9 @@ func bunchCacheJanitor() {
|
||||||
|
|
||||||
// CachedBunchLock is held here
|
// CachedBunchLock is held here
|
||||||
keepIfAfter := time.Now().Add(-5*time.Minute)
|
keepIfAfter := time.Now().Add(-5*time.Minute)
|
||||||
for req, resp := range CachedBunchedRequests {
|
for req, resp := range BunchCache {
|
||||||
if !resp.Timestamp.After(keepIfAfter) {
|
if !resp.Timestamp.After(keepIfAfter) {
|
||||||
delete(CachedBunchedRequests, req)
|
delete(BunchCache, req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BunchCacheLastCleanup = time.Now()
|
BunchCacheLastCleanup = time.Now()
|
||||||
|
@ -427,9 +427,9 @@ func HandleBunchedRemoteCommand(conn *websocket.Conn, client *ClientInfo, msg Cl
|
||||||
br := BunchedRequestFromCM(&msg)
|
br := BunchedRequestFromCM(&msg)
|
||||||
|
|
||||||
cacheStatus := func() byte {
|
cacheStatus := func() byte {
|
||||||
CachedBunchLock.RLock()
|
BunchCacheLock.RLock()
|
||||||
defer CachedBunchLock.RUnlock()
|
defer BunchCacheLock.RUnlock()
|
||||||
bresp, ok := CachedBunchedRequests[br]
|
bresp, ok := BunchCache[br]
|
||||||
if ok && bresp.Timestamp.After(time.Now().Add(-5*time.Minute)) {
|
if ok && bresp.Timestamp.After(time.Now().Add(-5*time.Minute)) {
|
||||||
client.MsgChannelKeepalive.Add(1)
|
client.MsgChannelKeepalive.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -482,9 +482,9 @@ func HandleBunchedRemoteCommand(conn *websocket.Conn, client *ClientInfo, msg Cl
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
CachedBunchLock.Lock()
|
BunchCacheLock.Lock()
|
||||||
CachedBunchedRequests[request] = BunchedResponse{Response: respStr, Timestamp: time.Now()}
|
BunchCache[request] = CachedBunchedResponse{Response: respStr, Timestamp: time.Now()}
|
||||||
CachedBunchLock.Unlock()
|
BunchCacheLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingBunchLock.Lock()
|
PendingBunchLock.Lock()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue