This commit is contained in:
shoopea 2020-01-16 21:31:56 +08:00
parent 1c44e5bc34
commit bb91db0e6a

View File

@ -1,8 +1,10 @@
package main package main
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"strings" "strings"
"time" "time"
@ -27,7 +29,8 @@ func loadClients() {
cx := ChirpClient{} cx := ChirpClient{}
copier.Copy(&cx, &c) copier.Copy(&cx, &c)
cx.Active = false cx.Active = false
clients[cx.TGUserID64] = cx clients[cx.TGUserID64] = &cx
log.Printf("loadClients[%s] : %p\n", cx.Login, &cx)
} }
muxClients.Unlock() muxClients.Unlock()
@ -151,9 +154,9 @@ func getLockedClient(id int64, createMissing bool) (*ChirpClient, bool) {
c.Mux.Lock() c.Mux.Lock()
muxClients.RUnlock() muxClients.RUnlock()
muxClients.Lock() muxClients.Lock()
clients[id] = c clients[id] = &c
muxClients.Unlock() muxClients.Unlock()
return c, true return &c, true
} else { } else {
muxClients.RUnlock() muxClients.RUnlock()
//c := new(ChirpClient) //c := new(ChirpClient)