Skip to content

Commit

Permalink
Update docs, remove needless condition check
Browse files Browse the repository at this point in the history
  • Loading branch information
josebalius committed Oct 7, 2021
1 parent 97cbdca commit 1ff58a3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/liveshare/port_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions pkg/liveshare/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 1 addition & 5 deletions pkg/liveshare/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1ff58a3

Please sign in to comment.