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

Method Close

pkg/wslconn/wslconn.go:138–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136}
137
138func (conn *WslConn) Close() error {
139 defer conn.FireConnChangeEvent()
140 conn.WithLock(func() {
141 if conn.Status == Status_Connected || conn.Status == Status_Connecting {
142 // if status is init, disconnected, or error don't change it
143 conn.Status = Status_Disconnected
144 }
145 conn.close_nolock()
146 })
147 // we must wait for the waiter to complete
148 startTime := time.Now()
149 for conn.HasWaiter.Load() {
150 time.Sleep(10 * time.Millisecond)
151 if time.Since(startTime) > 2*time.Second {
152 return fmt.Errorf("timeout waiting for waiter to complete")
153 }
154 }
155 return nil
156}
157
158func (conn *WslConn) close_nolock() {
159 // does not set status (that should happen at another level)

Callers 1

ReconnectMethod · 0.95

Calls 3

FireConnChangeEventMethod · 0.95
WithLockMethod · 0.95
close_nolockMethod · 0.95

Tested by

no test coverage detected