MCPcopy Index your code
hub / github.com/cli/cli / Close

Method Close

internal/codespaces/connection/connection.go:107–122  ·  view source on GitHub ↗

Close closes the underlying tunnel client SSH connection.

()

Source from the content-addressed store, hash-verified

105
106// Close closes the underlying tunnel client SSH connection.
107func (c *CodespaceConnection) Close() error {
108 // Lock the mutex to prevent race conditions with the underlying SSH connection
109 c.TunnelClient.mu.Lock()
110 defer c.TunnelClient.mu.Unlock()
111
112 // Don't close if we're not connected
113 if c.TunnelClient != nil && c.TunnelClient.connected {
114 if err := c.TunnelClient.Close(); err != nil {
115 return fmt.Errorf("failed to close tunnel client connection: %w", err)
116 }
117
118 c.TunnelClient.connected = false
119 }
120
121 return nil
122}
123
124// getTunnelManager creates a tunnel manager for the given codespace.
125// The tunnel manager is used to get the tunnel hosted in the codespace that we

Callers 1

Calls 2

CloseMethod · 0.65
ErrorfMethod · 0.65

Tested by 1