Skip to content
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

Select on connection close channel to prevent sending to a closed connection #3

Closed
antoniomika opened this issue Mar 10, 2019 · 1 comment
Assignees

Comments

@antoniomika
Copy link
Owner

Recent error found in demo instance:

panic: send on closed channel

goroutine 4128 [running]:
main.main.func4.1(0xc00024f380, 0xc000150880)
	/usr/local/go/src/github.com/antoniomika/sish/main.go:152 +0xa1
created by main.main.func4
	/usr/local/go/src/github.com/antoniomika/sish/main.go:142 +0x2d2

In regards to this change:

sish/main.go

Lines 142 to 156 in cc916eb

go func() {
time.Sleep(1 * time.Second)
count := 0
holderConn.Listeners.Range(func(key, value interface{}) bool {
count++
return true
})
if count == 0 {
holderConn.Messages <- "No forwarding requests sent. Closing connection."
time.Sleep(1 * time.Millisecond)
holderConn.CleanUp(state)
}
}()

A quick fix for this would be to change this function to have

select {
case <-holderConn.Close:
	return
default:
	holderConn.Messages <- "No forwarding requests sent. Closing connection."
	time.Sleep(1 * time.Millisecond)
	holderConn.CleanUp(state)
}

or similar. A quick fix in the meantime would be to start the process with -sish.cleanupunbound=false

@antoniomika antoniomika self-assigned this Mar 10, 2019
@antoniomika
Copy link
Owner Author

Resolved by: afba880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant