File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ public IPacket Set(IPacket data)
7070 /// 响应包:
7171 /// 键存在时返回存储的原始字节(ArrayPacket);
7272 /// 键不存在或存储未初始化时返回空包(Length=0)
73+ /// 注意:不能直接返回 IOwnerPacket(如 store.Get(key)),
74+ /// 因为 Remoting 框架在 ApiServer.Process 的 finally 块中调用
75+ /// DisposeHelper.TryDispose(result) 释放控制器返回值,
76+ /// 会在网络层发送前就将 OwnerPacket 的池化缓冲区归还,导致客户端收到乱码而超时。
77+ /// 改用 ArrayPacket 封装独立堆数组,TryDispose 检测到非 IDisposable 时跳过。
7378 /// </returns>
7479 public IPacket Get ( IPacket data )
7580 {
@@ -80,7 +85,8 @@ public IPacket Get(IPacket data)
8085 using var pk = store . Get ( key ) ;
8186 if ( pk == null ) return KvPacket . EncodeEmpty ( ) ;
8287
83- // GetSpan() 直接读取底层缓冲区,避免 ReadBytes() 分配中间字节数组,再包装 IPacket 的双重分配
88+ // 通过 GetSpan() 直接读取底层缓冲区并复制到新数组,避免 ReadBytes() + 再包装 IPacket 的双重分配。
89+ // 不能直接 return pk,原因见上方注释。
8490 return new ArrayPacket ( pk . GetSpan ( ) . ToArray ( ) ) ;
8591 }
8692
You can’t perform that action at this time.
0 commit comments