Compare commits
2 Commits
eb3926e575
...
0c5ddac9f5
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c5ddac9f5 | |||
| c08a3abf83 |
@ -112,9 +112,11 @@ func (pe *prometheusExporter) loop(ctx context.Context) {
|
||||
return
|
||||
|
||||
case req := <-pe.writerChan:
|
||||
if collector != nil {
|
||||
if m := collector.metrics[req.key]; m != nil {
|
||||
atomic.StoreUint64(m.valptr, math.Float64bits(req.val))
|
||||
}
|
||||
}
|
||||
|
||||
case nm := <-pe.registerChan:
|
||||
var nextmetrics map[string]*prometheusMetricDesc
|
||||
|
||||
@ -52,6 +52,7 @@ type commandType string
|
||||
const (
|
||||
commandType_EnterRoom = commandType("enter_room")
|
||||
commandType_LeaveRoom = commandType("leave_room")
|
||||
ForceShutdownCloseMessage = "force_shutdown"
|
||||
)
|
||||
|
||||
type commandMessage struct {
|
||||
@ -302,6 +303,7 @@ func (ws *WebsocketHandler) mainLoop(ctx context.Context) {
|
||||
logger.Println(r)
|
||||
}
|
||||
}()
|
||||
c.closeMessage = ForceShutdownCloseMessage
|
||||
ws.ClientDisconnected(c)
|
||||
c.Close()
|
||||
}
|
||||
@ -495,6 +497,11 @@ func upgrade_core(ws *WebsocketHandler, conn *websocket.Conn, accid primitive.Ob
|
||||
|
||||
ws.connWaitGroup.Add(1)
|
||||
go func(c *wsconn, accid primitive.ObjectID, deliveryChan chan<- any) {
|
||||
defer func() {
|
||||
recover()
|
||||
ws.connWaitGroup.Done()
|
||||
}()
|
||||
|
||||
for {
|
||||
messageType, r, err := c.NextReader()
|
||||
if err != nil {
|
||||
@ -519,10 +526,10 @@ func upgrade_core(ws *WebsocketHandler, conn *websocket.Conn, accid primitive.Ob
|
||||
ws.Call(newconn.sender, string(cmd), r)
|
||||
}
|
||||
}
|
||||
ws.connWaitGroup.Done()
|
||||
|
||||
c.Conn = nil
|
||||
if c.closeMessage != ForceShutdownCloseMessage {
|
||||
ws.connInOutChan <- c
|
||||
}
|
||||
}(newconn, accid, ws.deliveryChan)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user