summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f1a906a)
raw | patch | inline | side by side (parent: f1a906a)
author | Nick Hengeveld <nickh@reactrix.com> | |
Fri, 21 Oct 2005 19:06:20 +0000 (12:06 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 22 Oct 2005 02:20:18 +0000 (19:20 -0700) |
Switched back to loading alternates as needed
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
http-fetch.c | patch | blob | history |
diff --git a/http-fetch.c b/http-fetch.c
index d26fae8472ccdb986228580c8afbbe2f63fb575a..ed1053ade3e7e71251bfcf890cb304c7ce928222 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
#define PREV_BUF_SIZE 4096
#define RANGE_HEADER_SIZE 30
+static int got_alternates = 0;
static int active_requests = 0;
static int data_received;
int in_use;
int done;
CURLcode curl_result;
+ long http_code;
struct active_request_slot *next;
};
static void process_curl_messages(void);
static void process_request_queue(void);
#endif
+static int fetch_alternates(char *base);
static CURL* get_curl_handle(void)
{
slot->done = 1;
slot->in_use = 0;
slot->curl_result = curl_message->data.result;
+ curl_easy_getinfo(slot->curl,
+ CURLINFO_HTTP_CODE,
+ &slot->http_code);
request = request_queue_head;
while (request != NULL &&
request->slot != slot)
if (request != NULL) {
request->curl_result =
curl_message->data.result;
- curl_easy_getinfo(slot->curl,
- CURLINFO_HTTP_CODE,
- &request->http_code);
+ request->http_code = slot->http_code;
request->slot = NULL;
+ request->state = COMPLETE;
/* Use alternates if necessary */
- if (request->http_code == 404 &&
- request->repo->next != NULL) {
- request->repo = request->repo->next;
- start_request(request);
+ if (request->http_code == 404) {
+ fetch_alternates(alt->base);
+ if (request->repo->next != NULL) {
+ request->repo =
+ request->repo->next;
+ start_request(request);
+ }
} else {
finish_request(request);
- request->state = COMPLETE;
}
}
} else {
struct active_request_slot *slot;
+ if (got_alternates)
+ return 0;
+
data = xmalloc(4096);
buffer.size = 4096;
buffer.posn = 0;
run_active_slot(slot);
if (slot->curl_result != CURLE_OK) {
free(buffer.buffer);
+ if (slot->http_code == 404)
+ got_alternates = 1;
return 0;
}
}
i = posn + 1;
}
+ got_alternates = 1;
free(buffer.buffer);
return ret;
}
run_active_slot(request->slot);
#ifndef USE_CURL_MULTI
request->curl_result = request->slot->curl_result;
- curl_easy_getinfo(request->slot->curl,
- CURLINFO_HTTP_CODE,
- &request->http_code);
+ request->http_code = request->slot->http_code;
request->slot = NULL;
/* Use alternates if necessary */
- if (request->http_code == 404 &&
- request->repo->next != NULL) {
- request->repo = request->repo->next;
- start_request(request);
+ if (request->http_code == 404) {
+ fetch_alternates(alt->base);
+ if (request->repo->next != NULL) {
+ request->repo = request->repo->next;
+ start_request(request);
+ }
} else {
finish_request(request);
request->state = COMPLETE;
while (altbase) {
if (!fetch_pack(altbase, sha1))
return 0;
+ fetch_alternates(alt->base);
altbase = altbase->next;
}
return error("Unable to find %s under %s\n", sha1_to_hex(sha1),
alt->got_indices = 0;
alt->packs = NULL;
alt->next = NULL;
- fetch_alternates(alt->base);
if (pull(commit_id))
return 1;