Phase 16.4: Fix SSH server crash - increase stdin timeout and poll iteration
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

修改内容:
- max_poll_iterations: 500 → 2000 (200秒)
- stdin timeout: 300 → 1500 iterations (150秒)
- 支持50MB+大文件传输

目的:
- 防止SSH server过早崩溃
- 给rsync足够时间处理数据
- 确保大文件传输稳定

测试验证:待完成(需重新测试50MB和100MB)
This commit is contained in:
Warren
2026-06-17 23:08:37 +08:00
parent d5d1b00a54
commit 664a3e1944
2 changed files with 49 additions and 7 deletions
+7 -7
View File
@@ -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次poll30s)无数据
// ⭐⭐⭐⭐⭐ Phase 16.4修复:增加stdin超时机制(支持大文件传输)
// 如果stdin未关闭,且超过1500次poll150s)无数据
// 强制关闭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;