This commit is contained in:
shoopea 2019-12-15 16:05:44 +08:00
parent 5817d2f814
commit 1169a6b87f

View File

@ -36,11 +36,13 @@ func setClientIdle(userID64 int64, from time.Time) error {
}
func getLockedIdleClient() (*ChirpClient, error) {
fmt.Printf("getLockedIdleClient : starting.\n")
muxClients.RLock()
ids := make([]int64, 0)
for _, c := range clients {
if c.CWIdle {
ids = append(ids, c.TGUserID64)
fmt.Printf("getLockedIdleClient : appending %s (%d).\n", c.Login, c.TGUserID64)
}
}
muxClients.RUnlock()
@ -50,6 +52,7 @@ func getLockedIdleClient() (*ChirpClient, error) {
RndMux.Lock()
id := RndSrc.Intn(len(ids))
fmt.Printf("getLockedIdleClient : pulled (%d).\n", id)
RndMux.Unlock()
clients[ids[id]].Mux.Lock()