Skip to content

Race condition issue for curl_global_init and curl_global_cleanup on multi threads #10

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

Closed
leventkaragol opened this issue Apr 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@leventkaragol
Copy link
Owner

When the curl_global_init and curl_global_cleanup methods are called again on each HttpRequest object, if many HttpRequests are used in parallel in a multi-thread structure, it causes a race condition and causes one thread to cleanup before the other one finishes its work, resulting in undefined behavior. To prevent this, the curl_global_init method should be called once for the first HttpRequest and should not be called again. Similarly, the curl_global_cleanup method must be called once when exiting the application.

However, these calls should not be left to the user. It should be automated with static methods and mutex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant