Skip to content

Commit 1668537

Browse files
committed
dial: rename a few variables
1 parent b13d3b7 commit 1668537

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dial.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type SSHConn struct {
5252
stdout io.ReadCloser
5353

5454
shutdownMtx sync.Mutex
55-
shutdownResult *shutdownResult
55+
shutdownResult *shutdownResult // TODO not used anywhere
5656
cmdCancel context.CancelFunc
5757
}
5858

@@ -151,24 +151,24 @@ func (conn *SSHConn) shutdownProcess() *shutdownResult {
151151
return conn.shutdownResult
152152
}
153153

154-
termSuccessful := make(chan error, 1)
154+
wait := make(chan error, 1)
155155
go func() {
156156
if err := conn.cmd.Process.Signal(syscall.SIGTERM); err != nil {
157157
// TODO log error
158158
return
159159
}
160-
termSuccessful <- conn.cmd.Wait()
160+
wait <- conn.cmd.Wait()
161161
}()
162162

163163
timeout := time.NewTimer(1 * time.Second) // FIXME const
164164
defer timeout.Stop()
165165

166166
select {
167-
case waitErr := <-termSuccessful:
167+
case waitErr := <-wait:
168168
conn.shutdownResult = &shutdownResult{waitErr}
169169
case <-timeout.C:
170170
conn.cmdCancel()
171-
waitErr := conn.cmd.Wait()
171+
waitErr := <- wait // reuse existing Wait invocation, must not call twice
172172
conn.shutdownResult = &shutdownResult{waitErr}
173173
}
174174
return conn.shutdownResult
@@ -185,7 +185,7 @@ func (conn *SSHConn) Cmd() *exec.Cmd {
185185
// which usually results in SIGKILL being sent to the process.
186186
// Intended for integration tests, regular users shouldn't use it.
187187
func (conn *SSHConn) CmdCancel() {
188-
conn.cmdCancel()
188+
conn.cmdCancel()
189189
}
190190

191191
const bannerMessageLen = 31

0 commit comments

Comments
 (0)