{"thread":{"id":"2352","subject":"[PATCH 1/4] Verify remote packs, speed up pending request queue","startedAt":"2005-11-04T22:22:18Z","lastAt":"2005-11-04T22:22:18Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"11159","messageId":"20051104222218.GD3001@reactrix.com","threadId":"2352","inReplyTo":null,"subject":"[PATCH 1/4] Verify remote packs, speed up pending request queue","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-11-04T22:22:18Z","receivedAt":"2005-11-04T22:22:18Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Verify that remote packs exist before using the pack index, add requests to\nthe beginning of the queue to locate pending requests faster.\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\n http-push.c |   37 +++++++++++++++++++++----------------\n 1 files changed, 21 insertions(+), 16 deletions(-)\n\napplies-to: aaaf3e5d771c5de11e2c4da6677f51c7e07f7a50\n216264d37339c149efa8c2eb03dbf03f2812d5d1\ndiff --git a/http-push.c b/http-push.c\nindex e85f1c1..134d405 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -727,7 +727,6 @@ void process_waiting_requests(void)\n void add_request(unsigned char *sha1, char *lock_token)\n {\n \tstruct transfer_request *request = request_queue_head;\n-\tstruct transfer_request *tail;\n \tstruct packed_git *target;\n \t\n \twhile (request != NULL && memcmp(request->sha1, sha1, 20))\n@@ -745,17 +744,8 @@ void add_request(unsigned char *sha1, ch\n \trequest->lock_token = lock_token;\n \trequest->headers = NULL;\n \trequest->state = NEED_CHECK;\n-\trequest->next = NULL;\n-\n-\tif (request_queue_head == NULL) {\n-\t\trequest_queue_head = request;\n-\t} else {\n-\t\ttail = request_queue_head;\n-\t\twhile (tail->next != NULL) {\n-\t\t\ttail = tail->next;\n-\t\t}\n-\t\ttail->next = request;\n-\t}\n+\trequest->next = request_queue_head;\n+\trequest_queue_head = request;\n #ifdef USE_CURL_MULTI\n \tprocess_request_queue();\n \tprocess_curl_messages();\n@@ -775,13 +765,29 @@ static int fetch_index(unsigned char *sh\n \tFILE *indexfile;\n \tstruct active_request_slot *slot;\n \n+\t/* Don't use the index if the pack isn't there */\n+\turl = xmalloc(strlen(remote->url) + 65);\n+\tsprintf(url, \"%s/objects/pack/pack-%s.pack\", remote->url, hex);\n+\tslot = get_active_slot();\n+\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);\n+\tif (start_active_slot(slot)) {\n+\t\trun_active_slot(slot);\n+\t\tif (slot->curl_result != CURLE_OK) {\n+\t\t\tfree(url);\n+\t\t\treturn error(\"Unable to verify pack %s is available\",\n+\t\t\t\t     hex);\n+\t\t}\n+\t} else {\n+\t\treturn error(\"Unable to start request\");\n+\t}\n+\n \tif (has_pack_index(sha1))\n \t\treturn 0;\n \n \tif (push_verbosely)\n \t\tfprintf(stderr, \"Getting index for pack %s\\n\", hex);\n \t\n-\turl = xmalloc(strlen(remote->url) + 64);\n \tsprintf(url, \"%s/objects/pack/pack-%s.idx\", remote->url, hex);\n \t\n \tfilename = sha1_pack_index_name(sha1);\n@@ -792,6 +798,8 @@ static int fetch_index(unsigned char *sh\n \t\t\t     filename);\n \n \tslot = get_active_slot();\n+\tcurl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n \tcurl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n@@ -833,8 +841,6 @@ static int fetch_index(unsigned char *sh\n static int setup_index(unsigned char *sha1)\n {\n \tstruct packed_git *new_pack;\n-\tif (has_pack_file(sha1))\n-\t\treturn 0; // don't list this as something we can get\n \n \tif (fetch_index(sha1))\n \t\treturn -1;\n@@ -1610,7 +1616,6 @@ int main(int argc, char **argv)\n \twhile (request != NULL) {\n \t\tnext_request = request->next;\n \t\trelease_request(request);\n-\t\tfree(request);\n \t\trequest = next_request;\n \t}\n \n---\n0.99.9.GIT\n"}]}