{"thread":{"id":"19685","subject":"[PATCH 04/23] http-push: send out fetch requests on queue","startedAt":"2009-06-05T16:01:37Z","lastAt":"2009-06-06T01:14:22Z","messageCount":3,"participants":["Tay Ray Chuan","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":23},"messages":[{"id":"115521","messageId":"20090606000137.ff05ba37.rctay89@gmail.com","threadId":"19685","inReplyTo":null,"subject":"[PATCH 04/23] http-push: send out fetch requests on queue","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-06-05T16:01:37Z","receivedAt":"2009-06-05T16:01:37Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Previously, requests for remote files were simply added to the queue\n(pointed to by request_queue_head) and no transfer actually took\nplace[1], even though code that followed may rely on these remote files\nto be present (eg. the setup_revisions invocation).\n\nThe code that sends out the requests on the request queue is refactored\ninto the method run_request_queue.\n\nAfter the get_dav_remote_heads invocation (ie. after fetch requests are\nadded to the queue), the requests on the queue are sent out through an\ninvocation to run_request_queue.\n\nThis invocation to run_request_queue entails adding a fill function\nbefore pushing checks take place, which may lead to accidental,\nunwanted pushes previously.\n\nThe flag is_running_queue is introduced to prevent this from occurring.\nfill_active_slot is made to check the flag is_running_queue before\nthe sending of the requests proceeds.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c          |   37 ++++++++++++++++++++++++++-----------\n t/t5540-http-push.sh |    4 ++--\n 2 files changed, 28 insertions(+), 13 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 0b12ffe..218e263 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -846,11 +846,12 @@ static void finish_request(struct transfer_request *request)\n }\n\n #ifdef USE_CURL_MULTI\n+static int is_running_queue;\n static int fill_active_slot(void *unused)\n {\n \tstruct transfer_request *request;\n\n-\tif (aborted)\n+\tif (aborted || !is_running_queue)\n \t\treturn 0;\n\n \tfor (request = request_queue_head; request; request = request->next) {\n@@ -2174,6 +2175,25 @@ static int delete_remote_branch(char *pattern, int force)\n \treturn 0;\n }\n\n+void run_request_queue()\n+{\n+#ifdef USE_CURL_MULTI\n+\tis_running_queue = 1;\n+\tfill_active_slots();\n+\tadd_fill_function(NULL, fill_active_slot);\n+#endif\n+\tdo {\n+\t\tfinish_all_active_slots();\n+#ifdef USE_CURL_MULTI\n+\t\tfill_active_slots();\n+#endif\n+\t} while (request_queue_head && !aborted);\n+\n+#ifdef USE_CURL_MULTI\n+\tis_running_queue = 0;\n+#endif\n+}\n+\n int main(int argc, char **argv)\n {\n \tstruct transfer_request *request;\n@@ -2278,6 +2298,8 @@ int main(int argc, char **argv)\n \t\trepo->url = rewritten_url;\n \t}\n\n+\tis_running_queue = 0;\n+\n \t/* Verify DAV compliance/lock support */\n \tif (!locking_available()) {\n \t\trc = 1;\n@@ -2307,6 +2329,7 @@ int main(int argc, char **argv)\n \tlocal_refs = get_local_heads();\n \tfprintf(stderr, \"Fetching remote heads...\\n\");\n \tget_dav_remote_heads();\n+\trun_request_queue();\n\n \t/* Remove a remote branch if -d or -D was specified */\n \tif (delete_branch) {\n@@ -2436,16 +2459,8 @@ int main(int argc, char **argv)\n \t\tif (objects_to_send)\n \t\t\tfprintf(stderr, \"    sending %d objects\\n\",\n \t\t\t\tobjects_to_send);\n-#ifdef USE_CURL_MULTI\n-\t\tfill_active_slots();\n-\t\tadd_fill_function(NULL, fill_active_slot);\n-#endif\n-\t\tdo {\n-\t\t\tfinish_all_active_slots();\n-#ifdef USE_CURL_MULTI\n-\t\t\tfill_active_slots();\n-#endif\n-\t\t} while (request_queue_head && !aborted);\n+\n+\t\trun_request_queue();\n\n \t\t/* Update the remote branch if all went well */\n \t\tif (aborted || !update_remote(ref->new_sha1, ref_lock))\ndiff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh\nindex ad0f14b..f4a2cf6 100755\n--- a/t/t5540-http-push.sh\n+++ b/t/t5540-http-push.sh\n@@ -67,7 +67,7 @@ test_expect_success ' push to remote repository with unpacked refs' '\n \t test $HEAD = $(git rev-parse --verify HEAD))\n '\n\n-test_expect_failure 'http-push fetches unpacked objects' '\n+test_expect_success 'http-push fetches unpacked objects' '\n \tcp -R \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git \\\n \t\t\"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo_unpacked.git &&\n\n@@ -83,7 +83,7 @@ test_expect_failure 'http-push fetches unpacked objects' '\n \t git push -f -v $HTTPD_URL/test_repo_unpacked.git master)\n '\n\n-test_expect_failure 'http-push fetches packed objects' '\n+test_expect_success 'http-push fetches packed objects' '\n \tcp -R \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git \\\n \t\t\"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo_packed.git &&\n\n--\n1.6.3.1\n"},{"id":"115563","messageId":"m3r5xy5s1n.fsf@localhost.localdomain","threadId":"19685","inReplyTo":"20090606000137.ff05ba37.rctay89@gmail.com","subject":"Re: [PATCH 04/23] http-push: send out fetch requests on queue","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-06-05T20:44:56Z","receivedAt":"2009-06-05T20:44:56Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> Previously, requests for remote files were simply added to the queue\n> (pointed to by request_queue_head) and no transfer actually took\n> place[1], even though code that followed may rely on these remote files\n       ^^^\n       ^^^--- you have footnote reference, but no footnote\n\n> to be present (eg. the setup_revisions invocation).\n> \n> The code that sends out the requests on the request queue is refactored\n> into the method run_request_queue.\n> \n> After the get_dav_remote_heads invocation (ie. after fetch requests are\n> added to the queue), the requests on the queue are sent out through an\n> invocation to run_request_queue.\n> \n> This invocation to run_request_queue entails adding a fill function\n> before pushing checks take place, which may lead to accidental,\n> unwanted pushes previously.\n> \n> The flag is_running_queue is introduced to prevent this from occurring.\n> fill_active_slot is made to check the flag is_running_queue before\n> the sending of the requests proceeds.\n> \n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n[...]\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"115591","messageId":"be6fef0d0906051814v5fd82b9ds7a6d735603491326@mail.gmail.com","threadId":"19685","inReplyTo":"m3r5xy5s1n.fsf@localhost.localdomain","subject":"Re: [PATCH 04/23] http-push: send out fetch requests on queue","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-06-06T01:14:22Z","receivedAt":"2009-06-06T01:14:22Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, Jun 6, 2009 at 4:44 AM, Jakub Narebski<jnareb@gmail.com> wrote:\n>> Previously, requests for remote files were simply added to the queue\n>> (pointed to by request_queue_head) and no transfer actually took\n>> place[1], even though code that followed may rely on these remote files\n>       ^^^\n>       ^^^--- you have footnote reference, but no footnote\n\nThanks for catching this.\n\n-- \nCheers,\nRay Chuan\n"}]}