File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ type Command struct {
3737
3838 done chan struct {}
3939 cancel chan struct {}
40- once sync.Once
4140}
4241
4342func newCommand (ctx context.Context , shell * Shell , ids string ) * Command {
@@ -114,24 +113,19 @@ func (c *Command) check() error {
114113
115114// Close will terminate the running command
116115func (c * Command ) Close () error {
117- var err error
118-
119- if err = c .check (); err != nil {
116+ if err := c .check (); err != nil {
120117 return err
121118 }
122119
123- if _ , ok := <- c .cancel ; ! ok {
124- return nil // channel already closed, do not send a signal
125- }
120+ close (c .cancel )
126121
127- c . once . Do ( func () {
128- close ( c . cancel )
122+ id := c . id
123+ c . id = ""
129124
130- request := NewSignalRequest (c .client .url , c .shell .id , c . id , & c .client .Parameters )
131- defer request .Free ()
125+ request := NewSignalRequest (c .client .url , c .shell .id , id , & c .client .Parameters )
126+ defer request .Free ()
132127
133- _ , err = c .client .sendRequest (request )
134- })
128+ _ , err := c .client .sendRequest (request )
135129
136130 return err
137131}
You can’t perform that action at this time.
0 commit comments