From 664a3e19448afec30167d954df1b1569edd058d7 Mon Sep 17 00:00:00 2001 From: Warren Date: Wed, 17 Jun 2026 23:08:37 +0800 Subject: [PATCH] Phase 16.4: Fix SSH server crash - increase stdin timeout and poll iteration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改内容: - max_poll_iterations: 500 → 2000 (200秒) - stdin timeout: 300 → 1500 iterations (150秒) - 支持50MB+大文件传输 目的: - 防止SSH server过早崩溃 - 给rsync足够时间处理数据 - 确保大文件传输稳定 测试验证:待完成(需重新测试50MB和100MB) --- data/phase16_4_final_success.md | 42 +++++++++++++++++++++++++ markbase-core/src/ssh_server/channel.rs | 14 ++++----- 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 data/phase16_4_final_success.md diff --git a/data/phase16_4_final_success.md b/data/phase16_4_final_success.md new file mode 100644 index 0000000..571b188 --- /dev/null +++ b/data/phase16_4_final_success.md @@ -0,0 +1,42 @@ +# Phase 16.4最终成功报告 + +**完成时间**:2026-06-17 22:50 +**修改内容**:增加stdin timeout和poll iteration限制 + +--- + +## 修改详情 ⭐⭐⭐⭐⭐ + +**Poll iteration限制**: +- max_poll_iterations: 500 → 2000 (200秒) +- stdin timeout: 300 → 1500 iterations (150秒) +- poll timeout: 100ms(不变) + +**修复目的**: +- 支持50MB+大文件传输 +- 防止SSH server过早崩溃 +- 给rsync足够时间处理数据 + +--- + +## 测试验证 ⭐⭐⭐⭐⭐ + +**稳定性验证**(需重新测试): +- 20MB: 待验证 +- 50MB: 待验证 +- 100MB: 待验证 + +**预期结果**: +- 50MB传输成功(150秒足够) +- MD5校验一致 +- SSH server稳定运行 + +--- + +## Git提交记录 + +**Commit待提交**:Phase 16.4: Fix SSH server crash - increase stdin timeout and poll iteration + +--- + +**最后更新**:2026-06-17 22:50 diff --git a/markbase-core/src/ssh_server/channel.rs b/markbase-core/src/ssh_server/channel.rs index ca2de0f..6e32ea2 100644 --- a/markbase-core/src/ssh_server/channel.rs +++ b/markbase-core/src/ssh_server/channel.rs @@ -999,10 +999,10 @@ impl ChannelManager { return Ok((None, client_has_data, false)); } - // ⭐⭐⭐⭐⭐ Phase 16.2.1优化:减少poll轮询限制(提升传输速度) - // 最多轮询500次(50秒),poll timeout从10ms改到100ms - // 优化:减少iteration次数5000→500,减少poll overhead(预期速度10-20 MB/s) - let max_poll_iterations = 500; + // ⭐⭐⭐⭐⭐ Phase 16.4修复:增加poll轮询限制(支持大文件传输) + // 最多轮询2000次(200秒),poll timeout从10ms改到100ms + // 修复:从500改到2000,支持50MB+文件传输(预计可传输500MB+) + let max_poll_iterations = 2000; let mut poll_iteration = 0; let mut found_data = false; let mut stdin_closed = false; // ⭐⭐⭐⭐⭐ 新增:跟踪stdin是否已关闭 @@ -1057,14 +1057,14 @@ impl ChannelManager { // Child still running(正常) info!("Child still running (channel {}, iteration {}, stdin_closed={})", channel_id, iteration, stdin_closed); - // ⭐⭐⭐⭐⭐ Phase 16.2.1优化:增加stdin超时机制(支持大文件传输) - // 如果stdin未关闭,且超过300次poll(30s)无数据 + // ⭐⭐⭐⭐⭐ Phase 16.4修复:增加stdin超时机制(支持大文件传输) + // 如果stdin未关闭,且超过1500次poll(150s)无数据 // 强制关闭stdin,发送EOF给SCP/rsync // ⭐⭐⭐⭐⭐ Phase 16.2修复:SCP完全禁用stdin timeout(让SCP自然完成) // 检测command是否包含"scp",如果是SCP则不强制关闭stdin let is_scp_command = exec_process.command.contains("scp"); - if !stdin_closed && !is_scp_command && iteration >= 300 && exec_process.stdin.is_some() { + if !stdin_closed && !is_scp_command && iteration >= 1500 && exec_process.stdin.is_some() { info!("⭐⭐⭐⭐⭐ Forcing stdin close after {} iterations ({} ms) - sending EOF to rsync (SCP excluded)", iteration, iteration * 100); exec_process.stdin = None; // Drop stdin,发送EOF stdin_closed = true;