{"thread":{"id":"4410","subject":"[PATCH] HTTP cleanup","startedAt":"2006-06-06T16:41:32Z","lastAt":"2006-06-06T21:27:36Z","messageCount":2,"participants":["Nick Hengeveld","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21328","messageId":"20060606164131.GB3938@reactrix.com","threadId":"4410","inReplyTo":null,"subject":"[PATCH] HTTP cleanup","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2006-06-06T16:41:32Z","receivedAt":"2006-06-06T16:41:32Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Fix broken build when USE_CURL_MULTI is not defined, as noted by Becky Bruce.\n\nDuring cleanup, free header slist that was created during init, as noted\nby Junio.\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n---\n\nI've verified that git will build with USE_CURL_MULTI commented out, but\nhave done very little testing of the resulting fetch/push binaries.\n\nhttp-push.c |    8 ++++++++\n http.c      |    5 +++++\n 2 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex b1c018a..40524a8 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -788,6 +788,7 @@ static void finish_request(struct transf\n \t}\n }\n \n+#ifdef USE_CURL_MULTI\n void fill_active_slots(void)\n {\n \tstruct transfer_request *request = request_queue_head;\n@@ -821,6 +822,7 @@ void fill_active_slots(void)\n \t\tslot = slot->next;\n \t}\n }\n+#endif\n \n static void get_remote_object_list(unsigned char parent);\n \n@@ -851,8 +853,10 @@ static void add_fetch_request(struct obj\n \trequest->next = request_queue_head;\n \trequest_queue_head = request;\n \n+#ifdef USE_CURL_MULTI\n \tfill_active_slots();\n \tstep_active_slots();\n+#endif\n }\n \n static int add_send_request(struct object *obj, struct remote_lock *lock)\n@@ -889,8 +893,10 @@ static int add_send_request(struct objec\n \trequest->next = request_queue_head;\n \trequest_queue_head = request;\n \n+#ifdef USE_CURL_MULTI\n \tfill_active_slots();\n \tstep_active_slots();\n+#endif\n \n \treturn 1;\n }\n@@ -2523,7 +2529,9 @@ 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+#endif\n \t\tfinish_all_active_slots();\n \n \t\t/* Update the remote branch if all went well */\ndiff --git a/http.c b/http.c\nindex 146cf7b..a2e8e78 100644\n--- a/http.c\n+++ b/http.c\n@@ -287,6 +287,7 @@ #ifdef USE_CURL_MULTI\n #endif\n \tcurl_global_cleanup();\n \t\n+\tcurl_slist_free_all(pragma_header);\n }\n \n struct active_request_slot *get_active_slot(void)\n@@ -438,11 +439,15 @@ void release_active_slot(struct active_r\n {\n \tclosedown_active_slot(slot);\n \tif (slot->curl) {\n+#ifdef USE_CURL_MULTI\n \t\tcurl_multi_remove_handle(curlm, slot->curl);\n+#endif\n \t\tcurl_easy_cleanup(slot->curl);\n \t\tslot->curl = NULL;\n \t}\n+#ifdef USE_CURL_MULTI\n \tfill_active_slots();\n+#endif\n }\n \n static void finish_active_slot(struct active_request_slot *slot)\n-- \n1.3.3.g423a-dirty\n"},{"id":"21344","messageId":"7v4pyyotyv.fsf@assigned-by-dhcp.cox.net","threadId":"4410","inReplyTo":"20060606164131.GB3938@reactrix.com","subject":"Re: [PATCH] HTTP cleanup","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-06T21:27:36Z","receivedAt":"2006-06-06T21:27:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  I think this is needed on top of it.\n\n-- >8 --\n[PATCH] HTTP cleanup\n\nThis ifdef's out more functions that are not used while !USE_MULTI\nin http code.  Also the dependency of http related objects on http.h\nheader file was missing in the Makefile.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n Makefile    |    3 ++-\n http-push.c |   70 ++++++++++++++++++++++++++++++-----------------------------\n 2 files changed, 38 insertions(+), 35 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 004c216..f802043 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -552,7 +552,7 @@ http.o: http.c\n \t$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"' $<\n \n ifdef NO_EXPAT\n-http-fetch.o: http-fetch.c\n+http-fetch.o: http-fetch.c http.h\n \t$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<\n endif\n \n@@ -576,6 +576,7 @@ git-ssh-push$X: rsh.o\n \n git-imap-send$X: imap-send.o $(LIB_FILE)\n \n+http.o http-fetch.o http-push.o: http.h\n git-http-fetch$X: fetch.o http.o http-fetch.o $(LIB_FILE)\n \t$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\ndiff --git a/http-push.c b/http-push.c\nindex 40524a8..b39b36b 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -186,6 +186,7 @@ static void process_response(void *callb\n \tfinish_request(request);\n }\n \n+#ifdef USE_CURL_MULTI\n static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,\n \t\t\t       void *data)\n {\n@@ -349,6 +350,41 @@ static void start_fetch_loose(struct tra\n \t}\n }\n \n+static void start_mkcol(struct transfer_request *request)\n+{\n+\tchar *hex = sha1_to_hex(request->obj->sha1);\n+\tstruct active_request_slot *slot;\n+\tchar *posn;\n+\n+\trequest->url = xmalloc(strlen(remote->url) + 13);\n+\tstrcpy(request->url, remote->url);\n+\tposn = request->url + strlen(remote->url);\n+\tstrcpy(posn, \"objects/\");\n+\tposn += 8;\n+\tmemcpy(posn, hex, 2);\n+\tposn += 2;\n+\tstrcpy(posn, \"/\");\n+\n+\tslot = get_active_slot();\n+\tslot->callback_func = process_response;\n+\tslot->callback_data = request;\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */\n+\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n+\n+\tif (start_active_slot(slot)) {\n+\t\trequest->slot = slot;\n+\t\trequest->state = RUN_MKCOL;\n+\t} else {\n+\t\trequest->state = ABORTED;\n+\t\tfree(request->url);\n+\t\trequest->url = NULL;\n+\t}\n+}\n+#endif\n+\n static void start_fetch_packed(struct transfer_request *request)\n {\n \tchar *url;\n@@ -438,40 +474,6 @@ static void start_fetch_packed(struct tr\n \t}\n }\n \n-static void start_mkcol(struct transfer_request *request)\n-{\n-\tchar *hex = sha1_to_hex(request->obj->sha1);\n-\tstruct active_request_slot *slot;\n-\tchar *posn;\n-\n-\trequest->url = xmalloc(strlen(remote->url) + 13);\n-\tstrcpy(request->url, remote->url);\n-\tposn = request->url + strlen(remote->url);\n-\tstrcpy(posn, \"objects/\");\n-\tposn += 8;\n-\tmemcpy(posn, hex, 2);\n-\tposn += 2;\n-\tstrcpy(posn, \"/\");\n-\n-\tslot = get_active_slot();\n-\tslot->callback_func = process_response;\n-\tslot->callback_data = request;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, request->url);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);\n-\n-\tif (start_active_slot(slot)) {\n-\t\trequest->slot = slot;\n-\t\trequest->state = RUN_MKCOL;\n-\t} else {\n-\t\trequest->state = ABORTED;\n-\t\tfree(request->url);\n-\t\trequest->url = NULL;\n-\t}\n-}\n-\n static void start_put(struct transfer_request *request)\n {\n \tchar *hex = sha1_to_hex(request->obj->sha1);\n-- \n1.4.0.rc1.g9c41\n"}]}