Netflix-Skunkworks / spectatord

A high performance metrics daemon
Apache License 2.0
24 stars 5 forks source link

enable connection reuse in libcurl #80

Open copperlight opened 11 months ago

copperlight commented 11 months ago

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.

Fixes #51.