Commit 23f28b5
Fix SSH agent forwarding goroutine leak via missing half-close
When a guest process disconnects from the agent socket,
io.Copy(channel, unixConn) returns but the channel write side
stays open. The host's ServeAgent blocks reading the channel
waiting for a request that never comes, and the guest's reverse
copy blocks waiting for a response. Neither side ever closes,
leaking both goroutines and a maxAgentConns semaphore slot.
After 8 leaked connections (maxAgentConns), all new agent socket
connections are rejected, breaking SSH agent forwarding for the
rest of the session. Symptoms: git operations succeed for the
first few minutes then fail with "Permission denied (publickey)".
Fix: call channel.CloseWrite() after the guest->host copy
finishes, signaling EOF to the host so ServeAgent returns and
the full cleanup chain completes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 8a4bc2e commit 23f28b5
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| 516 | + | |
516 | 517 | | |
517 | 518 | | |
518 | 519 | | |
| |||
0 commit comments