-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic: close of closed channel #121
Comments
@masterzen I made a PR that attempts to fix this via |
@kke , do you by any chance have client code or a unit test that could reproduce the issue so that I understand how the double close was triggered? |
It goes something like this: shell, err := c.client.CreateShell()
if err != nil {
return err
}
defer shell.Close()
command, err := shell.Execute(cmd)
if err != nil {
return err
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
defer command.Stdin.Close()
command.Stdin.Write([]byte(stdin))
}()
wg.Add(1)
go func() {
defer wg.Done()
defer command.Stdout.Close()
outputScanner := bufio.NewScanner(command.Stdout)
for outputScanner.Scan() {
fmt.Print(outputScanner.Text()+"\n", "")
}
}()
command.Wait()
wg.Wait()
command.Close() It seems to occur in situations where a command is periodically retried. Anyway, to me it seems the select statement does not always do what it is supposed to. If it manages to read from the cancel channel, the channel remains open. Also I'm not sure if it's guaranteed to always hit that branch first. Also I don't know if it should even proceed to send the signal to endpoint if the channel is already closed. |
https://github.com/masterzen/winrm/blob/master/command.go#L111-L115
The text was updated successfully, but these errors were encountered: