MCPcopy
hub / github.com/wavetermdev/waveterm / connectInternal

Method connectInternal

pkg/wslconn/wslconn.go:671–699  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

669}
670
671func (conn *WslConn) connectInternal(ctx context.Context) error {
672 conn.Infof(ctx, "connectInternal %s\n", conn.GetName())
673 client, err := wsl.GetDistro(ctx, conn.Name)
674 if err != nil {
675 conn.Infof(ctx, "ERROR GetDistro: %s\n", err)
676 log.Printf("error: failed to get distro %s: %s\n", conn.GetName(), err)
677 return err
678 }
679 conn.WithLock(func() {
680 conn.Client = client
681 })
682 go func() {
683 defer func() {
684 panichandler.PanicHandler("wsl-waitForDisconnect", recover())
685 }()
686 conn.waitForDisconnect()
687 }()
688 wshResult := conn.tryEnableWsh(ctx, conn.GetName())
689 if !wshResult.WshEnabled {
690 if wshResult.WshError != nil {
691 conn.Infof(ctx, "ERROR enabling wsh: %v\n", wshResult.WshError)
692 conn.Infof(ctx, "will connect with wsh disabled\n")
693 } else {
694 conn.Infof(ctx, "wsh not enabled: %s\n", wshResult.NoWshReason)
695 }
696 }
697 conn.persistWshInstalled(ctx, wshResult)
698 return nil
699}
700
701func (conn *WslConn) waitForDisconnect() {
702 log.Printf("wait for disconnect in %+#v", conn)

Callers 1

ConnectMethod · 0.95

Calls 8

InfofMethod · 0.95
GetNameMethod · 0.95
WithLockMethod · 0.95
waitForDisconnectMethod · 0.95
tryEnableWshMethod · 0.95
persistWshInstalledMethod · 0.95
GetDistroFunction · 0.92
PanicHandlerFunction · 0.92

Tested by

no test coverage detected