Phase 16.1: Fix SCP stdin timeout (final analysis: abandon SCP legacy, recommend rsync)
修改内容: - stdin timeout: 从500 iterations (5s) 改到3000 (30s) - max_poll_iterations: 从1000改到5000 (50s) - SCP完全禁用stdin timeout (is_scp_command检测) 测试结果: - ❌ SCP 20MB失败 (只传输12MB, 400 KB/s) - ✅ rsync 20MB成功 (MD5一致, 780 KB/s) - 结论:SCP legacy protocol效率低,放弃SCP,推荐rsync 决策:方案3 - 放弃SCP legacy,推荐rsync (见phase16_1_scp_analysis.md) 下一步:Phase 16.2 - 性能优化 (提升780 KB/s到21-36 MB/s)
This commit is contained in:
@@ -997,10 +997,10 @@ impl ChannelManager {
|
||||
return Ok((None, client_has_data, false));
|
||||
}
|
||||
|
||||
// ⭐⭐⭐⭐⭐ Phase 14.2修复:增加poll轮询限制(支持大文件传输)
|
||||
// 最多轮询1000次(10秒),如果持续无数据,检查child状态
|
||||
// 修复:从100改到1000,配合stdin close timeout(500 iterations = 5s)
|
||||
let max_poll_iterations = 1000;
|
||||
// ⭐⭐⭐⭐⭐ Phase 16.1修复:增加poll轮询限制(支持SCP大文件传输)
|
||||
// 最多轮询5000次(50秒),如果持续无数据,检查child状态
|
||||
// 修复:从1000改到5000,支持SCP大文件传输(预计可传输500MB+)
|
||||
let max_poll_iterations = 5000;
|
||||
let mut poll_iteration = 0;
|
||||
let mut found_data = false;
|
||||
let mut stdin_closed = false; // ⭐⭐⭐⭐⭐ 新增:跟踪stdin是否已关闭
|
||||
@@ -1053,12 +1053,15 @@ impl ChannelManager {
|
||||
// Child still running(正常)
|
||||
info!("Child still running (channel {}, iteration {}, stdin_closed={})", channel_id, iteration, stdin_closed);
|
||||
|
||||
// ⭐⭐⭐⭐⭐ Phase 14.2修复:增加stdin超时机制(支持大文件传输)
|
||||
// 如果stdin未关闭,且超过500次poll(5s)无数据
|
||||
// 强制关闭stdin,发送EOF给rsync
|
||||
// 修复:从50改到500,支持大文件传输(预计可传输50MB+)
|
||||
if !stdin_closed && iteration >= 500 && exec_process.stdin.is_some() {
|
||||
info!("⭐⭐⭐⭐⭐ Forcing stdin close after {} iterations ({} ms) - sending EOF to rsync", iteration, iteration * 10);
|
||||
// ⭐⭐⭐⭐⭐ Phase 16.1修复:增加stdin超时机制(支持SCP大文件传输)
|
||||
// 如果stdin未关闭,且超过3000次poll(30s)无数据
|
||||
// 强制关闭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 >= 3000 && exec_process.stdin.is_some() {
|
||||
info!("⭐⭐⭐⭐⭐ Forcing stdin close after {} iterations ({} ms) - sending EOF to rsync (SCP excluded)", iteration, iteration * 10);
|
||||
exec_process.stdin = None; // Drop stdin,发送EOF
|
||||
stdin_closed = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user