All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Hengeveld <nickh@reactrix.com>
To: git@vger.kernel.org
Subject: [PATCH 1/4] Verify remote packs, speed up pending request queue
Date: Fri, 4 Nov 2005 14:22:18 -0800	[thread overview]
Message-ID: <20051104222218.GD3001@reactrix.com> (raw)

Verify that remote packs exist before using the pack index, add requests to
the beginning of the queue to locate pending requests faster.

Signed-off-by: Nick Hengeveld <nickh@reactrix.com>


---

 http-push.c |   37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)

applies-to: aaaf3e5d771c5de11e2c4da6677f51c7e07f7a50
216264d37339c149efa8c2eb03dbf03f2812d5d1
diff --git a/http-push.c b/http-push.c
index e85f1c1..134d405 100644
--- a/http-push.c
+++ b/http-push.c
@@ -727,7 +727,6 @@ void process_waiting_requests(void)
 void add_request(unsigned char *sha1, char *lock_token)
 {
 	struct transfer_request *request = request_queue_head;
-	struct transfer_request *tail;
 	struct packed_git *target;
 	
 	while (request != NULL && memcmp(request->sha1, sha1, 20))
@@ -745,17 +744,8 @@ void add_request(unsigned char *sha1, ch
 	request->lock_token = lock_token;
 	request->headers = NULL;
 	request->state = NEED_CHECK;
-	request->next = NULL;
-
-	if (request_queue_head == NULL) {
-		request_queue_head = request;
-	} else {
-		tail = request_queue_head;
-		while (tail->next != NULL) {
-			tail = tail->next;
-		}
-		tail->next = request;
-	}
+	request->next = request_queue_head;
+	request_queue_head = request;
 #ifdef USE_CURL_MULTI
 	process_request_queue();
 	process_curl_messages();
@@ -775,13 +765,29 @@ static int fetch_index(unsigned char *sh
 	FILE *indexfile;
 	struct active_request_slot *slot;
 
+	/* Don't use the index if the pack isn't there */
+	url = xmalloc(strlen(remote->url) + 65);
+	sprintf(url, "%s/objects/pack/pack-%s.pack", remote->url, hex);
+	slot = get_active_slot();
+	curl_easy_setopt(slot->curl, CURLOPT_URL, url);
+	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
+	if (start_active_slot(slot)) {
+		run_active_slot(slot);
+		if (slot->curl_result != CURLE_OK) {
+			free(url);
+			return error("Unable to verify pack %s is available",
+				     hex);
+		}
+	} else {
+		return error("Unable to start request");
+	}
+
 	if (has_pack_index(sha1))
 		return 0;
 
 	if (push_verbosely)
 		fprintf(stderr, "Getting index for pack %s\n", hex);
 	
-	url = xmalloc(strlen(remote->url) + 64);
 	sprintf(url, "%s/objects/pack/pack-%s.idx", remote->url, hex);
 	
 	filename = sha1_pack_index_name(sha1);
@@ -792,6 +798,8 @@ static int fetch_index(unsigned char *sh
 			     filename);
 
 	slot = get_active_slot();
+	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
+	curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);
 	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
 	curl_easy_setopt(slot->curl, CURLOPT_URL, url);
@@ -833,8 +841,6 @@ static int fetch_index(unsigned char *sh
 static int setup_index(unsigned char *sha1)
 {
 	struct packed_git *new_pack;
-	if (has_pack_file(sha1))
-		return 0; // don't list this as something we can get
 
 	if (fetch_index(sha1))
 		return -1;
@@ -1610,7 +1616,6 @@ int main(int argc, char **argv)
 	while (request != NULL) {
 		next_request = request->next;
 		release_request(request);
-		free(request);
 		request = next_request;
 	}
 
---
0.99.9.GIT

                 reply	other threads:[~2005-11-04 22:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051104222218.GD3001@reactrix.com \
    --to=nickh@reactrix.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.