Merge branch 'jc/rebase-limit'
[gitweb.git] / http.c
diff --git a/http.c b/http.c
index 75e6717a9411dcb5fa3b575de4c5703e5ce47514..14a7669cd427e101985d4acf8f3da3314937eeaa 100644 (file)
--- a/http.c
+++ b/http.c
@@ -192,6 +192,9 @@ static CURL* get_curl_handle(void)
 
        curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
 
+       if (getenv("GIT_CURL_VERBOSE"))
+               curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
+
        return result;
 }
 
@@ -335,6 +338,7 @@ struct active_request_slot *get_active_slot(void)
        active_requests++;
        slot->in_use = 1;
        slot->local = NULL;
+       slot->results = NULL;
        slot->callback_data = NULL;
        slot->callback_func = NULL;
        curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);
@@ -416,12 +420,34 @@ void run_active_slot(struct active_request_slot *slot)
 #endif
 }
 
-static void finish_active_slot(struct active_request_slot *slot)
+static void closedown_active_slot(struct active_request_slot *slot)
 {
         active_requests--;
         slot->in_use = 0;
+}
+
+void release_active_slot(struct active_request_slot *slot)
+{
+       closedown_active_slot(slot);
+       if (slot->curl) {
+               curl_multi_remove_handle(curlm, slot->curl);
+               curl_easy_cleanup(slot->curl);
+               slot->curl = NULL;
+       }
+       fill_active_slots();
+}
+
+static void finish_active_slot(struct active_request_slot *slot)
+{
+       closedown_active_slot(slot);
         curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
+
+       /* Store slot results so they can be read after the slot is reused */
+       if (slot->results != NULL) {
+               slot->results->curl_result = slot->curl_result;
+               slot->results->http_code = slot->http_code;
+       }
+
         /* Run callback if appropriate */
         if (slot->callback_func != NULL) {
                 slot->callback_func(slot->callback_data);