Originally, in the HttpClient::perform() method, a new CurlHandle was created
upon every invocation, leading to subsequent calls to curl_easy_init() and
curl_easy_cleanup(), as the variable went in and out of scope while it executed
on the asio::thread_pool. This meant that there was no opportunity to reuse
connections from the underlying connection pool, because it was always cleaned up.
By marking the CurlHandle with the thread_local storage duration, it ensures
that the same one remains in use for each thread, thus providing the means to
reuse the established connection pool.
Originally, in the
HttpClient::perform()
method, a newCurlHandle
was created upon every invocation, leading to subsequent calls tocurl_easy_init()
andcurl_easy_cleanup()
, as the variable went in and out of scope while it executed on theasio::thread_pool
. This meant that there was no opportunity to reuse connections from the underlying connection pool, because it was always cleaned up.By marking the
CurlHandle
with thethread_local
storage duration, it ensures that the same one remains in use for each thread, thus providing the means to reuse the established connection pool.Fixes #51.