X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=http.c;h=0cb42a85d146c406f8268be423aabeb9e0e90dd0;hb=87840620fd77e39a0df91dc8b8db6cfdb5e4845a;hp=eefb0f03d2f7ac30163e69b842f6943987cf9351;hpb=c8568e139ed2149fbfb7ef9a8d819d5b6b7c554f;p=git.git diff --git a/http.c b/http.c index eefb0f03..0cb42a85 100644 --- a/http.c +++ b/http.c @@ -192,6 +192,11 @@ 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); + + curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT); + return result; } @@ -336,6 +341,7 @@ struct active_request_slot *get_active_slot(void) slot->in_use = 1; slot->local = NULL; slot->results = NULL; + slot->finished = NULL; slot->callback_data = NULL; slot->callback_func = NULL; curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header); @@ -386,8 +392,10 @@ void run_active_slot(struct active_request_slot *slot) fd_set excfds; int max_fd; struct timeval select_timeout; + int finished = 0; - while (slot->in_use) { + slot->finished = &finished; + while (!finished) { data_received = 0; step_active_slots(); @@ -417,12 +425,31 @@ 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); + if (slot->finished != NULL) + (*slot->finished) = 1; + /* Store slot results so they can be read after the slot is reused */ if (slot->results != NULL) { slot->results->curl_result = slot->curl_result;