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

Prevent using RoundTripper after it was closed #485

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

mariusSincovici
Copy link
Contributor

Signed-off-by: Marius Sincovici [email protected]

The inner RoundTripper can be used by multiple requests in the same time. It can be closed on error or on VPN connection. This 2 operation(execute reques + close) can overlap resulting in a crash because requests are using a closed RoundTripper.
To prevent the crash protect access to RoundTripper with a RWLock. Plus add an atomic.Bool to prevent recreating RoundTripper by 2 concurrent requests on the same error.

@mariusSincovici mariusSincovici marked this pull request as ready for review July 4, 2024 08:26
Signed-off-by: Marius Sincovici <[email protected]>

The inner RoundTripper can be used by multiple requests in the same time.
It can be closed on error or on VPN connection. This 2 operation can overlap
resulting in a crash because requests are using a closed RoundTripper.
To prevent the crash protect access to RoundTripper with a RWLock.
Plus add an atomic.Bool to prevent recreating RoundTripper by 2 concurrent
requests on the same error.
@mariusSincovici mariusSincovici force-pushed the fix-race-condition-for-round-tripper branch from 021798a to 64791dd Compare July 8, 2024 09:09
@mariusSincovici mariusSincovici merged commit 21fc29e into main Jul 8, 2024
8 checks passed
@mariusSincovici mariusSincovici deleted the fix-race-condition-for-round-tripper branch July 8, 2024 10:25
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