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

channel: don't leak go routine on close #130

Merged
merged 2 commits into from
May 13, 2023
Merged

channel: don't leak go routine on close #130

merged 2 commits into from
May 13, 2023

Conversation

nemith
Copy link
Contributor

@nemith nemith commented May 9, 2023

The channel close has some timeout logic for block reads. If the timeout is hit (the `<-time.After(c.ReadDelay * (c.ReadDelay / readDelayDivisor) branch) then the go routine will block forever.

This changes the channel send to a close which will not block. Closed go routines will always send the zero value on any receivers which will do the right thing in both cases.

I am pretty sure there are other goroutine leaks in closing connections as well. c.done is used to signal closing of the channel but on the read() method there is a good chance the connection is blocking on c.Read() and so c.done is probably not going to be read:

func (c *Channel) read() {.

transport.Read() probably won't not block until closed, so the order of operation is backwards, but I haven't had a chance to dig into it and probably wont' be but something to look/test for.

@nemith nemith marked this pull request as ready for review May 9, 2023 18:33
@nemith
Copy link
Contributor Author

nemith commented May 9, 2023

uhhggg, that lint means well but..

@carlmontanari
Copy link
Contributor

heh, sorry for uh... shall we say... aggressive linters :) its to keep me from getting off the rails!

thanks for opening this and the context! looks good and sounds good and will check it out this weekend when I get a sec to process (seems totally reasonable just wanna make sure I have time to fully grok it!)! (and I can appease the silly linter when I get to it this weekend!)

@carlmontanari
Copy link
Contributor

dunno whats going on with actions, but thats a problem for later :) thanks again for this!

@carlmontanari carlmontanari merged commit ec6e666 into scrapli:main May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants