Update docs, remove needless condition check

This commit is contained in:
Jose Garcia 2021-10-07 16:39:43 -04:00
parent 97cbdca84a
commit 1ff58a3de7
3 changed files with 4 additions and 8 deletions

View file

@ -163,7 +163,7 @@ func (fwd *PortForwarder) handleConnection(ctx context.Context, id channelID, co
connReader io.Reader = conn
)
// If we the port forwader has been configured to keep the session alive
// If the forwader has been configured to keep the session alive
// it will monitor the I/O and notify the session of the traffic.
if fwd.keepAlive {
channelReader = newTrafficMonitor(channelReader, fwd.session, "output")

View file

@ -103,8 +103,8 @@ func (s *Session) StartSSHServer(ctx context.Context) (int, string, error) {
return port, response.User, nil
}
// heartbeat ticks every interval and sends a signal to the Live Share host to keep
// the connection alive if there is a reason to do so.
// heartbeat runs until context cancellation, periodically checking whether there is a
// reason to keep the connection alive, and if so, notifying the Live Share host to do so.
func (s *Session) heartbeat(ctx context.Context, interval time.Duration) {
ticker := time.NewTicker(interval)
defer ticker.Stop()

View file

@ -230,16 +230,12 @@ func TestInvalidHostKey(t *testing.T) {
func TestKeepAliveNonBlocking(t *testing.T) {
session := &Session{keepAliveReason: make(chan string, 1)}
var i int
for ; i < 2; i++ {
for i := 0; i < 2; i++ {
session.keepAlive("io")
}
// if keepAlive blocks, we'll never reach this and timeout the test
// timing out
if i != 2 {
t.Errorf("unexpected iteration account, expected: 2, got: %d", i)
}
}
func TestNotifyHostOfActivity(t *testing.T) {