summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 66f04f3)
raw | patch | inline | side by side (parent: 66f04f3)
author | Mark Wooding <mdw@distorted.org.uk> | |
Tue, 7 Feb 2006 10:07:39 +0000 (10:07 +0000) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 7 Feb 2006 10:13:02 +0000 (02:13 -0800) |
In fetch_object, there's a call to release an object request if the
object mysteriously arrived, say in a pack. Unfortunately, the fetch
attempt for this object might already be in progress, and we'll leak the
descriptor. Instead, try to tidy away the request.
Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
object mysteriously arrived, say in a pack. Unfortunately, the fetch
attempt for this object might already be in progress, and we'll leak the
descriptor. Instead, try to tidy away the request.
Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
http-fetch.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 bddbd6b10068edfa7786266feb276a404a9551e2..ce3df5f35c1fe16dbafec299ade95bb706d86e77 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
return 0;
}
+static void abort_object_request(struct object_request *obj_req)
+{
+ if (obj_req->local >= 0) {
+ close(obj_req->local);
+ obj_req->local = -1;
+ }
+ unlink(obj_req->tmpfile);
+ if (obj_req->slot) {
+ release_active_slot(obj_req->slot);
+ obj_req->slot = NULL;
+ }
+ release_object_request(obj_req);
+}
+
static int fetch_object(struct alt_base *repo, unsigned char *sha1)
{
char *hex = sha1_to_hex(sha1);
return error("Couldn't find request for %s in the queue", hex);
if (has_sha1_file(obj_req->sha1)) {
- release_object_request(obj_req);
+ abort_object_request(obj_req);
return 0;
}
index 632c2c5c2fcf2ef51092aa72d8c2dee64efbde49..14a7669cd427e101985d4acf8f3da3314937eeaa 100644 (file)
--- a/http.c
+++ b/http.c
#endif
}
-static void finish_active_slot(struct active_request_slot *slot)
+static void closedown_active_slot(struct active_request_slot *slot)
{
active_requests--;
slot->in_use = 0;
+}
+
+void release_active_slot(struct active_request_slot *slot)
+{
+ closedown_active_slot(slot);
+ if (slot->curl) {
+ curl_multi_remove_handle(curlm, slot->curl);
+ curl_easy_cleanup(slot->curl);
+ slot->curl = NULL;
+ }
+ fill_active_slots();
+}
+
+static void finish_active_slot(struct active_request_slot *slot)
+{
+ closedown_active_slot(slot);
curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
/* Store slot results so they can be read after the slot is reused */
index d6dc9d89fbc4be0fd5acd3e7bc50302da69f3d05..36fa154d2f6adf19bac3db4985360174320f0b8d 100644 (file)
--- a/http.h
+++ b/http.h
extern int start_active_slot(struct active_request_slot *slot);
extern void run_active_slot(struct active_request_slot *slot);
extern void finish_all_active_slots(void);
+extern void release_active_slot(struct active_request_slot *slot);
#ifdef USE_CURL_MULTI
extern void fill_active_slots(void);