Repository navigation
fix(gb28181): 停止点播后清理事务时不再误删新会话的 stream 索引 (#2216) - #2244
Merged
Merged
Conversation
问题(见 issue 648540858#2216):同一通道重复点播会覆盖 Redis 中以 app+stream 为键的 事务索引,而清除旧 Call-ID 时会无条件按旧事务的 app+stream 删除同一条索引, 把已经指向新 Dialog 的索引一并删掉;此后 stop/BYE 取不到事务,残留 Dialog 无法被终止,设备持续推送 RTP(孤儿 RTP)。 改动: 1. SipInviteSessionManager.removeByCallId:仅当 stream 索引仍指向当前 Call-ID 时才删除,避免误删已被新会话覆盖的索引(新增 isStreamIndexOwnedBy 判定)。 2. SIPCommander.streamByeCmd:把事务清理移到 BYE 成功发出之后,发送失败时 保留事务以便重试,不再出现'未发出 BYE 但事务已丢失'的状态。 3. 新增 SipInviteSessionManagerTest:用内存 Map 模拟 Redis Hash,覆盖 '清理旧 Call-ID 保留新索引'、'索引仍属本事务时正常删除'、null 边界。 验证:JDK 21 下 mvn -Dtest=SipInviteSessionManagerTest test -> Tests run: 3, Failures: 0, Errors: 0(pom 中 surefire skipTests 默认 true,运行时临时置 false, 提交不含 pom 改动)。未做:真实 GB28181 设备端到端验证(无设备), 同一 stream 多 Dialog 并存的数据模型改造(需维护者定方案)。
|
@CieveMe is attempting to deploy a commit to the 648540858's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
见 #2216:同一通道重复点播后关流,WVP 与 ZLMediaKit 的媒体列表已无该流,但设备仍持续发送 RTP(ZLMediaKit 中残留
RtpSession,入站带宽被持续占用),重复点播会继续叠加;stop返回成功,但只有当前记录的 Dialog 收到 BYE。根因复核(在 master
da1e588上逐条核对报告方给出的 4 条)MediaDepartureEvent两个@Async监听器竞态:先删InviteInfo,再想发 BYE 已取不到会话da1e588的isStaleStreamDeparture()大部分缓解(两侧都会跳过迟到的旧会话事件)SipInviteSessionManager.put以app+stream为单值索引,第二次点播覆盖第一个 Dialog 的索引put/get/remove与多处调用点,请您定方案removeByCallId无条件删除该事务的app+stream索引 → 清理旧 Call-ID 会误删新 Dialog 的索引PlayServiceImpl.stop在InviteInfo == null时直接返回;且streamByeCmd先删事务再发 BYE,发送失败即无法重试stop是否按 Call-ID 兜底清理)属产品口径,留给您③ 是孤儿 RTP 的直接成因:索引被删后
streamByeCmd按 stream 取不到事务,抛SsrcTransactionNotFoundException,残留 Dialog 永远收不到 BYE。改动(3 files, +148 −6)
SipInviteSessionManager.removeByCallId():删除 stream 索引前先比对索引是否仍指向当前 Call-ID(新增isStreamIndexOwnedBy()),不再误删已被新会话覆盖的索引。SIPCommander.streamByeCmd():把sessionManager.removeByCallId()移到transmitRequest()之后。原来是先删事务再发送,一旦构造/发送抛异常,事务已丢失而 BYE 并未发出,残留 Dialog 再也无法清理。SipInviteSessionManagerTest:3 个用例,用内存 Map 模拟 Redis Hash,不依赖 Redis 与 Spring 容器。验证
覆盖:清理旧 Call-ID 必须保留新事务的 stream 索引 / 索引仍属本事务时正常删除 /
isStreamIndexOwnedBy的 null 边界。可复现命令:本仓库
pom.xml的 surefire<skipTests>硬编码为true(直接跑只会输出Tests are skipped.),本地需临时改成false(该改动未提交),然后:未验证 / 不在范围
stop是否允许按 Call-ID 兜底清理)。这两条我都没有顺手改,避免把决策藏进补丁里。