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

Fix memory leak in ContextSerivce. #34

Merged
merged 1 commit into from
Mar 10, 2016
Merged

Conversation

gaplyk
Copy link
Contributor

@gaplyk gaplyk commented Mar 10, 2016

Make context.Background for each request to the server. (When it's global, this cause memory leak)
Remove ContextWithIP and ContextWithForwardForIP. Could be used in ContextMiddleware
Add WithCloseHandler middleware


// WithCloseHandler returns a Handler cancelling the context when the client
// connection close unexpectedly.
func WithCloseHandler(h ContextHandler) ContextHandler {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you calling this anywhere? Or just bringing the function into the toolkit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I do

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of copy/paste straight from rs/xhandler, could you just use their xhandler.CloseHandler instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to use additional library? and we have different types.
Just tried - we could not use

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I thought they interface was compatible, but since we have a ServeHTTPContext where they have ServeHTTPC, you're right that it's not an easy drop-in.

Go ahead and leave this for now.

@jprobinson
Copy link
Contributor

Looks good! Thanks, @gaplyk!

jprobinson added a commit that referenced this pull request Mar 10, 2016
Fix memory leak in ContextSerivce.
@jprobinson jprobinson merged commit fbee99c into nytimes:master Mar 10, 2016
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.

None yet

2 participants