Skip to content

Conversation

qustavo
Copy link

@qustavo qustavo commented Mar 19, 2018

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

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