mrtazz / restclient-cpp

C++ client for making HTTP/REST requests
http://code.mrtazz.com/restclient-cpp/
MIT License
1.57k stars 377 forks source link

not thread-safe #154

Closed ubiqoracle closed 4 years ago

ubiqoracle commented 4 years ago

Expected behaviour (not thread-safe)

I found Thread Safety on the top page. I tried RestClient::init() before restclient-cpp GET PUT in multi-threading to produce thread-not-safe.

Should I put RestClient::init() in each thread or init() once before multi-threads? Is it possible to provide a sample code (multi-threads) to show it's not thread-safe? so we can use it with caution in multi-threads.

Actual behaviour

it went through without thread-not-safe

Environment and debugging details

mrtazz commented 4 years ago

The RestClient::init() and RestClient::disable() methods basically correspond to curl_global_init and curl_global_cleanup and thus need to be called right at the beginning of your program and before shutdown respectively. These set up the environment and are not thread-safe.

This is from the docs. The methods need to be called outside of any threading at the start of the program. Let me know if there is a way to make the docs more clear.