mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-07-12 13:32:34 +02:00
replace mutex-guarded maps with xsync/v2 maps.
This commit is contained in:
9
start.go
9
start.go
@ -50,11 +50,10 @@ func (rl *Relay) Start(host string, port int, started ...chan bool) error {
|
||||
func (rl *Relay) Shutdown(ctx context.Context) {
|
||||
rl.httpServer.Shutdown(ctx)
|
||||
|
||||
rl.clientsMu.Lock()
|
||||
defer rl.clientsMu.Unlock()
|
||||
for conn := range rl.clients {
|
||||
rl.clients.Range(func(conn *websocket.Conn, _ struct{}) bool {
|
||||
conn.WriteControl(websocket.CloseMessage, nil, time.Now().Add(time.Second))
|
||||
conn.Close()
|
||||
delete(rl.clients, conn)
|
||||
}
|
||||
rl.clients.Delete(conn)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user