summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ec5755)
raw | patch | inline | side by side (parent: 7ec5755)
author | Nick Hengeveld <nickh@reactrix.com> | |
Tue, 31 Jan 2006 19:06:55 +0000 (11:06 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 1 Feb 2006 00:17:24 +0000 (16:17 -0800) |
Add a way to store the results of an HTTP request when a slot finishes
so the results can be processed after the slot has been reused.
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
so the results can be processed after the slot has been reused.
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
http-fetch.c | patch | blob | history | |
http.c | patch | blob | history | |
http.h | patch | blob | history |
diff --git a/http-fetch.c b/http-fetch.c
index 61b2188adbb68d94b2d5906be63c89bda879b4b0..92326f9ac50bfb0edecb762d81e26fa134bcf120 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
FILE *indexfile;
struct active_request_slot *slot;
+ static struct slot_results results;
if (has_pack_index(sha1))
return 0;
filename);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK) {
fclose(indexfile);
return error("Unable to get pack index %s\n%s", url,
curl_errorstr);
int i = 0;
struct active_request_slot *slot;
+ static struct slot_results results;
if (repo->got_indices)
return 0;
sprintf(url, "%s/objects/info/packs", repo->base);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
- if (slot->http_code == 404 ||
- slot->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
+ if (results.curl_result != CURLE_OK) {
+ if (results.http_code == 404 ||
+ results.curl_result == CURLE_FILE_COULDNT_READ_FILE) {
repo->got_indices = 1;
free(buffer.buffer);
return 0;
struct curl_slist *range_header = NULL;
struct active_request_slot *slot;
+ static struct slot_results results;
if (fetch_indices(repo))
return -1;
filename);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, packfile);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK) {
+ if (results.curl_result != CURLE_OK) {
fclose(packfile);
return error("Unable to get pack file %s\n%s", url,
curl_errorstr);
struct buffer buffer;
char *base = alt->base;
struct active_request_slot *slot;
+ static struct slot_results results;
buffer.size = 41;
buffer.posn = 0;
buffer.buffer = hex;
url = quote_ref_url(base, ref);
slot = get_active_slot();
+ slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
if (start_active_slot(slot)) {
run_active_slot(slot);
- if (slot->curl_result != CURLE_OK)
+ if (results.curl_result != CURLE_OK)
return error("Couldn't get %s for %s\n%s",
url, ref, curl_errorstr);
} else {
index 75e6717a9411dcb5fa3b575de4c5703e5ce47514..eefb0f03d2f7ac30163e69b842f6943987cf9351 100644 (file)
--- a/http.c
+++ b/http.c
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);
active_requests--;
slot->in_use = 0;
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);
index ed4ea3340e48307e087a311136d1fe4f74b2d607..d6dc9d89fbc4be0fd5acd3e7bc50302da69f3d05 100644 (file)
--- a/http.h
+++ b/http.h
#define NO_CURL_EASY_DUPHANDLE
#endif
+struct slot_results
+{
+ CURLcode curl_result;
+ long http_code;
+};
+
struct active_request_slot
{
CURL *curl;
int in_use;
CURLcode curl_result;
long http_code;
+ struct slot_results *results;
void *callback_data;
void (*callback_func)(void *data);
struct active_request_slot *next;