+static CURL *get_connection(AzureStore *store)
+{
+ CURL *curl = NULL;
+
+ g_mutex_lock(store->curl_pool_lock);
+ if (!g_queue_is_empty(store->curl_pool)) {
+ curl = (CURL *)(g_queue_pop_head(store->curl_pool));
+ }
+ g_mutex_unlock(store->curl_pool_lock);
+
+ if (curl == NULL)
+ curl = curl_easy_init();
+
+ return curl;
+}
+
+static void put_connection(AzureStore *store, CURL *curl)
+{
+ g_mutex_lock(store->curl_pool_lock);
+ g_queue_push_head(store->curl_pool, curl);
+ while (g_queue_get_length(store->curl_pool) > MAX_IDLE_CONNECTIONS) {
+ curl = (CURL *)(g_queue_pop_tail(store->curl_pool));
+ curl_easy_cleanup(curl);
+ }
+ g_mutex_unlock(store->curl_pool_lock);
+}
+