fix(notify): 根治低带宽控制面阻塞与传输写入卡死
- 为控制消息增加优先级、公平调度、队列字节预算和自适应批处理 - 支持可取消的写门等待,收紧 shared/dedicated bulk、stream 和 Reply 写入边界 - 修复 bulk reset/close、连接 handoff 和安全 profile 切换时序 - 保留旧取消与超时错误契约,新增阶段化 TransportSendError - 增加 ReplyCtx、ReplyObjCtx、写超时配置及黑洞连接和竞态回归测试
This commit is contained in:
+31
-2
@@ -370,7 +370,7 @@ func (s *ServerCommon) sendFastBulkDataTransport(ctx context.Context, logical *L
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.writeEnvelopePayload(logical, transport, nil, payload)
|
||||
return s.writeEnvelopePayloadContext(ctx, logical, transport, nil, payload)
|
||||
}
|
||||
|
||||
func (s *ServerCommon) sendFastBulkWriteTransport(ctx context.Context, logical *LogicalConn, transport *TransportConn, dataID uint64, startSeq uint64, chunkSize int, fastPathVersion uint8, payload []byte, payloadOwned bool) (int, error) {
|
||||
@@ -439,7 +439,7 @@ func (s *ServerCommon) sendFastBulkControlTransport(ctx context.Context, logical
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.writeEnvelopePayload(logical, transport, nil, encoded)
|
||||
return s.writeEnvelopePayloadContext(ctx, logical, transport, nil, encoded)
|
||||
}
|
||||
|
||||
func (s *ServerCommon) encodeBulkFastControlPayloadLogical(logical *LogicalConn, frameType uint8, flags uint8, dataID uint64, seq uint64, payload []byte) ([]byte, error) {
|
||||
@@ -474,6 +474,9 @@ func transportFastPayloadMagic(payload []byte) string {
|
||||
|
||||
func (c *ClientCommon) decryptTransportPayloadPooled(payload []byte, release func()) ([]byte, func(), error) {
|
||||
profile := c.clientTransportProtectionSnapshot()
|
||||
if fallback := c.inboundTransitionProfile.Load(); fallback != nil {
|
||||
return decryptTransportPayloadWithFallbackPooled(profile, *fallback, payload, release)
|
||||
}
|
||||
return decryptTransportPayloadCodecPooled(profile.mode, profile.runtime, profile.msgDe, profile.secretKey, payload, release)
|
||||
}
|
||||
|
||||
@@ -484,9 +487,35 @@ func (s *ServerCommon) decryptTransportPayloadLogicalPooled(logical *LogicalConn
|
||||
}
|
||||
return nil, nil, errTransportDetached
|
||||
}
|
||||
if fallback := logical.inboundTransitionProfile.Load(); fallback != nil {
|
||||
profile := logical.transportProtectionProfileSnapshot()
|
||||
return decryptTransportPayloadWithFallbackPooled(profile, *fallback, payload, release)
|
||||
}
|
||||
return decryptTransportPayloadCodecPooled(logical.protectionModeSnapshot(), logical.modernPSKRuntimeSnapshot(), logical.msgDeSnapshot(), logical.secretKeySnapshot(), payload, release)
|
||||
}
|
||||
|
||||
func decryptTransportPayloadWithFallbackPooled(primary transportProtectionProfile, fallback transportProtectionProfile, payload []byte, release func()) ([]byte, func(), error) {
|
||||
profiles := [...]transportProtectionProfile{primary, fallback}
|
||||
for _, profile := range profiles {
|
||||
plain, plainRelease, err := decryptTransportPayloadCodecOwnedPooled(profile.mode, profile.runtime, profile.msgDe, profile.secretKey, payload)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if profile.mode == ProtectionExternal {
|
||||
plain = append([]byte(nil), plain...)
|
||||
plainRelease = nil
|
||||
}
|
||||
if release != nil {
|
||||
release()
|
||||
}
|
||||
return plain, plainRelease, nil
|
||||
}
|
||||
if release != nil {
|
||||
release()
|
||||
}
|
||||
return nil, nil, errTransportPayloadDecryptFailed
|
||||
}
|
||||
|
||||
func (c *ClientCommon) tryDispatchBorrowedTransportPlain(plain []byte, release func()) bool {
|
||||
switch transportFastPayloadMagic(plain) {
|
||||
case bulkFastPayloadMagic, bulkFastBatchMagic:
|
||||
|
||||
Reference in New Issue
Block a user