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

Close backendConn after use #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qustavo
Copy link

@qustavo qustavo commented Mar 19, 2018

Look like backend connection never get closed and we should after use it.

@@ -67,6 +67,8 @@ func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error
fullMethodName := lowLevelServerStream.Method()
// We require that the director's returned context inherits from the serverStream.Context().
outgoingCtx, backendConn, err := s.director(serverStream.Context(), fullMethodName)
defer backendConn.Close()
Copy link

@vgough vgough Dec 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go through the director, IMO. Also this shouldn't occur unless the call succeeds, otherwise you can get a NPE panic since backendConn may be nil.

Need for backend cleanup was noted in #16, which I've implemented on a separate branch: https://github.com/vgough/grpc-proxy/blob/master/proxy/handler.go#L71

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vgough. Isn't it enough to just 'defer backendConn.Close()' after checking if director returned an error to prevent nil pointer dereference

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're responding to a comment that's over 4 years old. I'm not using this anymore. Be sure to test your setup under load. Yes, at the very minimum there should be a nil check to avoid a NPE.

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

Successfully merging this pull request may close these issues.

3 participants