fix: 在 OnConnect 把 mochi 发送配额置 0 规避死锁
This commit is contained in:
@@ -67,6 +67,16 @@ func (h *nixHook) OnConnect(cl *mqtt.Client, pk packets.Packet) error {
|
||||
cl.State.ServerKeepalive = true
|
||||
}
|
||||
|
||||
// B-01:绕开 mochi 发送配额路径(NextImmediate 递归读锁 + PUBACK 配额泄漏)。
|
||||
// ParseConnect 已按客户端 Receive Maximum 设过 sendQuota;此处一律置 0。
|
||||
if cl.State.Inflight != nil {
|
||||
cl.State.Inflight.ResetSendQuota(0)
|
||||
}
|
||||
if rm := pk.Properties.ReceiveMaximum; rm > 0 && rm < 256 {
|
||||
h.b.log.Warn("client receive maximum below 256; server ignores MQTT send quota",
|
||||
"endpoint", endpointID, "receive_maximum", rm)
|
||||
}
|
||||
|
||||
res, err := h.b.auth.Authenticate(context.Background(), endpointID, pk.Connect.Password, remoteIP)
|
||||
if err != nil {
|
||||
st.authErr = err
|
||||
|
||||
Reference in New Issue
Block a user