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

removed use of sync.pool from HandleContext and added test coverage #1565

Merged
merged 3 commits into from
Oct 1, 2018
Merged

removed use of sync.pool from HandleContext and added test coverage #1565

merged 3 commits into from
Oct 1, 2018

Conversation

japettyjohn
Copy link
Contributor

As per #1230 there is an issue when using HandleContext where the context of the request is returned to the context sync.Pool before the parent request has finished, causing context to be used in a non-thread safe manner.

I've removed the bug by not entering the context back in the pool and leaving that to ServeHTTP.

There was no test coverage for this function so I've also added the test to cover it. As the bug only happens when there are concurrent requests, the tests issues hundreds of concurrent requests. Without the bug fixed the tests do consistently recreate the error.

@codecov
Copy link

codecov bot commented Sep 23, 2018

Codecov Report

Merging #1565 into master will increase coverage by 0.2%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1565     +/-   ##
=========================================
+ Coverage   99.06%   99.27%   +0.2%     
=========================================
  Files          39       39             
  Lines        1929     1928      -1     
=========================================
+ Hits         1911     1914      +3     
+ Misses         14       10      -4     
  Partials        4        4
Impacted Files Coverage Δ
gin.go 100% <ø> (+1.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91a4459...e090ffb. Read the comment docs.

@appleboy appleboy added this to the 1.4 milestone Sep 27, 2018
@appleboy appleboy merged commit e9f187f into gin-gonic:master Oct 1, 2018
justinfx pushed a commit to justinfx/gin that referenced this pull request Nov 3, 2018
…in-gonic#1565)

As per gin-gonic#1230 there is an issue when using HandleContext where the context of the request is returned to the context sync.Pool before the parent request has finished, causing context to be used in a non-thread safe manner.

I've removed the bug by not entering the context back in the pool and leaving that to ServeHTTP.

There was no test coverage for this function so I've also added the test to cover it. As the bug only happens when there are concurrent requests, the tests issues hundreds of concurrent requests. Without the bug fixed the tests do consistently recreate the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants