mirror of
https://github.com/git/git.git
synced 2024-12-14 04:18:16 +08:00
Merge branch 'jk/http-no-curl-easy'
Uses of curl's "multi" interface and "easy" interface do not mix well when we attempt to reuse outgoing connections. Teach the RPC over http code, used in the smart HTTP transport, not to use the "easy" interface. * jk/http-no-curl-easy: http: never use curl_easy_perform
This commit is contained in:
commit
b7de45b58e
24
http.c
24
http.c
@ -880,6 +880,20 @@ int handle_curl_result(struct slot_results *results)
|
||||
}
|
||||
}
|
||||
|
||||
int run_one_slot(struct active_request_slot *slot,
|
||||
struct slot_results *results)
|
||||
{
|
||||
slot->results = results;
|
||||
if (!start_active_slot(slot)) {
|
||||
snprintf(curl_errorstr, sizeof(curl_errorstr),
|
||||
"failed to start HTTP request");
|
||||
return HTTP_START_FAILED;
|
||||
}
|
||||
|
||||
run_active_slot(slot);
|
||||
return handle_curl_result(results);
|
||||
}
|
||||
|
||||
static CURLcode curlinfo_strbuf(CURL *curl, CURLINFO info, struct strbuf *buf)
|
||||
{
|
||||
char *ptr;
|
||||
@ -907,7 +921,6 @@ static int http_request(const char *url,
|
||||
int ret;
|
||||
|
||||
slot = get_active_slot();
|
||||
slot->results = &results;
|
||||
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
|
||||
|
||||
if (result == NULL) {
|
||||
@ -942,14 +955,7 @@ static int http_request(const char *url,
|
||||
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip");
|
||||
|
||||
if (start_active_slot(slot)) {
|
||||
run_active_slot(slot);
|
||||
ret = handle_curl_result(&results);
|
||||
} else {
|
||||
snprintf(curl_errorstr, sizeof(curl_errorstr),
|
||||
"failed to start HTTP request");
|
||||
ret = HTTP_START_FAILED;
|
||||
}
|
||||
ret = run_one_slot(slot, &results);
|
||||
|
||||
if (options && options->content_type)
|
||||
curlinfo_strbuf(slot->curl, CURLINFO_CONTENT_TYPE,
|
||||
|
9
http.h
9
http.h
@ -90,6 +90,15 @@ extern void finish_active_slot(struct active_request_slot *slot);
|
||||
extern void finish_all_active_slots(void);
|
||||
extern int handle_curl_result(struct slot_results *results);
|
||||
|
||||
/*
|
||||
* This will run one slot to completion in a blocking manner, similar to how
|
||||
* curl_easy_perform would work (but we don't want to use that, because
|
||||
* we do not want to intermingle calls to curl_multi and curl_easy).
|
||||
*
|
||||
*/
|
||||
int run_one_slot(struct active_request_slot *slot,
|
||||
struct slot_results *results);
|
||||
|
||||
#ifdef USE_CURL_MULTI
|
||||
extern void fill_active_slots(void);
|
||||
extern void add_fill_function(void *data, int (*fill)(void *));
|
||||
|
@ -423,11 +423,8 @@ static int run_slot(struct active_request_slot *slot,
|
||||
if (!results)
|
||||
results = &results_buf;
|
||||
|
||||
slot->results = results;
|
||||
slot->curl_result = curl_easy_perform(slot->curl);
|
||||
finish_active_slot(slot);
|
||||
err = run_one_slot(slot, results);
|
||||
|
||||
err = handle_curl_result(results);
|
||||
if (err != HTTP_OK && err != HTTP_REAUTH) {
|
||||
error("RPC failed; result=%d, HTTP code = %ld",
|
||||
results->curl_result, results->http_code);
|
||||
|
Loading…
Reference in New Issue
Block a user