summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 077d6f7)
raw | patch | inline | side by side (parent: 077d6f7)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Tue, 11 Sep 2007 03:02:28 +0000 (23:02 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 19 Sep 2007 10:22:29 +0000 (03:22 -0700) |
This removes all of the boilerplate and http-internal stuff from
fill_active_slots() and makes it easy to turn into a callback.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fill_active_slots() and makes it easy to turn into a callback.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http-fetch.c | patch | blob | history | |
http-push.c | patch | blob | history | |
http.c | patch | blob | history | |
http.h | patch | blob | history |
diff --git a/http-fetch.c b/http-fetch.c
index 202fae0ba8b348aeca6ec6c61045f39aa0d1fa66..e9b9f307f8f0a38326df56e9a827b261990734fe 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
}
#ifdef USE_CURL_MULTI
-void fill_active_slots(void)
+int fill_active_slot(void)
{
- struct object_request *obj_req = object_queue_head;
- struct active_request_slot *slot = active_queue_head;
- int num_transfers;
+ struct object_request *obj_req;
- while (active_requests < max_requests && obj_req != NULL) {
+ for (obj_req = object_queue_head; obj_req; obj_req = obj_req->next) {
if (obj_req->state == WAITING) {
if (has_sha1_file(obj_req->sha1))
obj_req->state = COMPLETE;
- else
+ else {
start_object_request(obj_req);
- curl_multi_perform(curlm, &num_transfers);
- }
- obj_req = obj_req->next;
- }
-
- while (slot != NULL) {
- if (!slot->in_use && slot->curl != NULL) {
- curl_easy_cleanup(slot->curl);
- slot->curl = NULL;
+ return 1;
+ }
}
- slot = slot->next;
}
+ return 0;
}
#endif
diff --git a/http-push.c b/http-push.c
index 7c3720f602bb8f50ed54a4f7e7a85c7e08d1c07b..c7471fa11d962afe79518d3916b542e1a2290604 100644 (file)
--- a/http-push.c
+++ b/http-push.c
}
#ifdef USE_CURL_MULTI
-void fill_active_slots(void)
+int fill_active_slot(void)
{
struct transfer_request *request = request_queue_head;
- struct transfer_request *next;
- struct active_request_slot *slot = active_queue_head;
- int num_transfers;
if (aborted)
- return;
+ return 0;
- while (active_requests < max_requests && request != NULL) {
- next = request->next;
+ for (request = request_queue_head; request; request = request->next) {
if (request->state == NEED_FETCH) {
start_fetch_loose(request);
+ return 1;
} else if (pushing && request->state == NEED_PUSH) {
if (remote_dir_exists[request->obj->sha1[0]] == 1) {
start_put(request);
} else {
start_mkcol(request);
}
- curl_multi_perform(curlm, &num_transfers);
- }
- request = next;
- }
-
- while (slot != NULL) {
- if (!slot->in_use && slot->curl != NULL) {
- curl_easy_cleanup(slot->curl);
- slot->curl = NULL;
+ return 1;
}
- slot = slot->next;
}
+ return 0;
}
#endif
index c6fb8ace9f9f43935f4128fc223b01e6cb9fa605..1f305bd355fd66e3cd01659e3ee1f894c3324a33 100644 (file)
--- a/http.c
+++ b/http.c
{
#ifdef USE_CURL_MULTI
CURLMcode curlm_result = curl_multi_add_handle(curlm, slot->curl);
+ int num_transfers;
if (curlm_result != CURLM_OK &&
curlm_result != CURLM_CALL_MULTI_PERFORM) {
slot->in_use = 0;
return 0;
}
+
+ /*
+ * We know there must be something to do, since we just added
+ * something.
+ */
+ curl_multi_perform(curlm, &num_transfers);
#endif
return 1;
}
#ifdef USE_CURL_MULTI
+void fill_active_slots(void)
+{
+ struct active_request_slot *slot = active_queue_head;
+
+ while (active_requests < max_requests)
+ if (!fill_active_slot())
+ break;
+
+ while (slot != NULL) {
+ if (!slot->in_use && slot->curl != NULL) {
+ curl_easy_cleanup(slot->curl);
+ slot->curl = NULL;
+ }
+ slot = slot->next;
+ }
+}
+
void step_active_slots(void)
{
int num_transfers;
index 69b6b667d956933eca7153b51867493d7271df0b..559105cc034467551041f9b57f7d649b3473f50a 100644 (file)
--- a/http.h
+++ b/http.h
#ifdef USE_CURL_MULTI
extern void fill_active_slots(void);
extern void step_active_slots(void);
+
+/* Provided by the program using http. */
+extern int fill_active_slot(void);
#endif
extern void http_init(void);
extern int data_received;
extern int active_requests;
-#ifdef USE_CURL_MULTI
-extern int max_requests;
-extern CURLM *curlm;
-#endif
#ifndef NO_CURL_EASY_DUPHANDLE
extern CURL *curl_default;
#endif
extern struct curl_slist *pragma_header;
extern struct curl_slist *no_range_header;
-extern struct active_request_slot *active_queue_head;
-
#endif /* HTTP_H */