* [PATCH] HTTP cleanup
@ 2006-06-06 16:41 Nick Hengeveld
2006-06-06 21:27 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Nick Hengeveld @ 2006-06-06 16:41 UTC (permalink / raw)
To: git
Fix broken build when USE_CURL_MULTI is not defined, as noted by Becky Bruce.
During cleanup, free header slist that was created during init, as noted
by Junio.
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
---
I've verified that git will build with USE_CURL_MULTI commented out, but
have done very little testing of the resulting fetch/push binaries.
http-push.c | 8 ++++++++
http.c | 5 +++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/http-push.c b/http-push.c
index b1c018a..40524a8 100644
--- a/http-push.c
+++ b/http-push.c
@@ -788,6 +788,7 @@ static void finish_request(struct transf
}
}
+#ifdef USE_CURL_MULTI
void fill_active_slots(void)
{
struct transfer_request *request = request_queue_head;
@@ -821,6 +822,7 @@ void fill_active_slots(void)
slot = slot->next;
}
}
+#endif
static void get_remote_object_list(unsigned char parent);
@@ -851,8 +853,10 @@ static void add_fetch_request(struct obj
request->next = request_queue_head;
request_queue_head = request;
+#ifdef USE_CURL_MULTI
fill_active_slots();
step_active_slots();
+#endif
}
static int add_send_request(struct object *obj, struct remote_lock *lock)
@@ -889,8 +893,10 @@ static int add_send_request(struct objec
request->next = request_queue_head;
request_queue_head = request;
+#ifdef USE_CURL_MULTI
fill_active_slots();
step_active_slots();
+#endif
return 1;
}
@@ -2523,7 +2529,9 @@ int main(int argc, char **argv)
if (objects_to_send)
fprintf(stderr, " sending %d objects\n",
objects_to_send);
+#ifdef USE_CURL_MULTI
fill_active_slots();
+#endif
finish_all_active_slots();
/* Update the remote branch if all went well */
diff --git a/http.c b/http.c
index 146cf7b..a2e8e78 100644
--- a/http.c
+++ b/http.c
@@ -287,6 +287,7 @@ #ifdef USE_CURL_MULTI
#endif
curl_global_cleanup();
+ curl_slist_free_all(pragma_header);
}
struct active_request_slot *get_active_slot(void)
@@ -438,11 +439,15 @@ void release_active_slot(struct active_r
{
closedown_active_slot(slot);
if (slot->curl) {
+#ifdef USE_CURL_MULTI
curl_multi_remove_handle(curlm, slot->curl);
+#endif
curl_easy_cleanup(slot->curl);
slot->curl = NULL;
}
+#ifdef USE_CURL_MULTI
fill_active_slots();
+#endif
}
static void finish_active_slot(struct active_request_slot *slot)
--
1.3.3.g423a-dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] HTTP cleanup
2006-06-06 16:41 [PATCH] HTTP cleanup Nick Hengeveld
@ 2006-06-06 21:27 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-06-06 21:27 UTC (permalink / raw)
To: Nick Hengeveld; +Cc: git
Thanks. I think this is needed on top of it.
-- >8 --
[PATCH] HTTP cleanup
This ifdef's out more functions that are not used while !USE_MULTI
in http code. Also the dependency of http related objects on http.h
header file was missing in the Makefile.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Makefile | 3 ++-
http-push.c | 70 ++++++++++++++++++++++++++++++-----------------------------
2 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile
index 004c216..f802043 100644
--- a/Makefile
+++ b/Makefile
@@ -552,7 +552,7 @@ http.o: http.c
$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
ifdef NO_EXPAT
-http-fetch.o: http-fetch.c
+http-fetch.o: http-fetch.c http.h
$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
endif
@@ -576,6 +576,7 @@ git-ssh-push$X: rsh.o
git-imap-send$X: imap-send.o $(LIB_FILE)
+http.o http-fetch.o http-push.o: http.h
git-http-fetch$X: fetch.o http.o http-fetch.o $(LIB_FILE)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
diff --git a/http-push.c b/http-push.c
index 40524a8..b39b36b 100644
--- a/http-push.c
+++ b/http-push.c
@@ -186,6 +186,7 @@ static void process_response(void *callb
finish_request(request);
}
+#ifdef USE_CURL_MULTI
static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
void *data)
{
@@ -349,6 +350,41 @@ static void start_fetch_loose(struct tra
}
}
+static void start_mkcol(struct transfer_request *request)
+{
+ char *hex = sha1_to_hex(request->obj->sha1);
+ struct active_request_slot *slot;
+ char *posn;
+
+ request->url = xmalloc(strlen(remote->url) + 13);
+ strcpy(request->url, remote->url);
+ posn = request->url + strlen(remote->url);
+ strcpy(posn, "objects/");
+ posn += 8;
+ memcpy(posn, hex, 2);
+ posn += 2;
+ strcpy(posn, "/");
+
+ slot = get_active_slot();
+ slot->callback_func = process_response;
+ slot->callback_data = request;
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */
+ curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
+ curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);
+ curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);
+ curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
+
+ if (start_active_slot(slot)) {
+ request->slot = slot;
+ request->state = RUN_MKCOL;
+ } else {
+ request->state = ABORTED;
+ free(request->url);
+ request->url = NULL;
+ }
+}
+#endif
+
static void start_fetch_packed(struct transfer_request *request)
{
char *url;
@@ -438,40 +474,6 @@ static void start_fetch_packed(struct tr
}
}
-static void start_mkcol(struct transfer_request *request)
-{
- char *hex = sha1_to_hex(request->obj->sha1);
- struct active_request_slot *slot;
- char *posn;
-
- request->url = xmalloc(strlen(remote->url) + 13);
- strcpy(request->url, remote->url);
- posn = request->url + strlen(remote->url);
- strcpy(posn, "objects/");
- posn += 8;
- memcpy(posn, hex, 2);
- posn += 2;
- strcpy(posn, "/");
-
- slot = get_active_slot();
- slot->callback_func = process_response;
- slot->callback_data = request;
- curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */
- curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
- curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);
- curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);
- curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
-
- if (start_active_slot(slot)) {
- request->slot = slot;
- request->state = RUN_MKCOL;
- } else {
- request->state = ABORTED;
- free(request->url);
- request->url = NULL;
- }
-}
-
static void start_put(struct transfer_request *request)
{
char *hex = sha1_to_hex(request->obj->sha1);
--
1.4.0.rc1.g9c41
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-06-06 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-06 16:41 [PATCH] HTTP cleanup Nick Hengeveld
2006-06-06 21:27 ` Junio C Hamano
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.