Phase 16.4: Fix SSH server crash - increase stdin timeout and poll iteration
Some checks failed
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

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;