* [PATCH 1/3] Clean up CURL handles in unused request slots
@ 2005-10-21 19:06 Nick Hengeveld
0 siblings, 0 replies; only message in thread
From: Nick Hengeveld @ 2005-10-21 19:06 UTC (permalink / raw)
To: git
Clean up CURL handles in unused request slots
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
---
While it's not clear whether this fixes any of the reported problems, it
seems safer to close connections that we know aren't in use.
http-fetch.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
applies-to: ce9a5a0fdd52a29e370d849a132b4509c844aca1
24cd59bf9c4f5519e7f529cdd5bf3a9fbec72e5e
diff --git a/http-fetch.c b/http-fetch.c
index a7dc2cc..d26fae8 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -291,11 +291,7 @@ static struct active_request_slot *get_a
}
if (slot == NULL) {
newslot = xmalloc(sizeof(*newslot));
-#ifdef NO_CURL_EASY_DUPHANDLE
- newslot->curl = get_curl_handle();
-#else
- newslot->curl = curl_easy_duphandle(curl_default);
-#endif
+ newslot->curl = NULL;
newslot->in_use = 0;
newslot->next = NULL;
@@ -311,6 +307,14 @@ static struct active_request_slot *get_a
slot = newslot;
}
+ if (slot->curl == NULL) {
+#ifdef NO_CURL_EASY_DUPHANDLE
+ slot->curl = get_curl_handle();
+#else
+ slot->curl = curl_easy_duphandle(curl_default);
+#endif
+ }
+
active_requests++;
slot->in_use = 1;
slot->done = 0;
@@ -612,6 +616,7 @@ void process_curl_messages(void)
void process_request_queue(void)
{
struct transfer_request *request = request_queue_head;
+ struct active_request_slot *slot = active_queue_head;
int num_transfers;
while (active_requests < max_requests && request != NULL) {
@@ -624,6 +629,14 @@ void process_request_queue(void)
}
request = request->next;
}
+
+ while (slot != NULL) {
+ if (!slot->in_use && slot->curl != NULL) {
+ curl_easy_cleanup(slot->curl);
+ slot->curl = NULL;
+ }
+ slot = slot->next;
+ }
}
#endif
@@ -1297,7 +1310,8 @@ int main(int argc, char **argv)
#endif
slot = active_queue_head;
while (slot != NULL) {
- curl_easy_cleanup(slot->curl);
+ if (slot->curl != NULL)
+ curl_easy_cleanup(slot->curl);
slot = slot->next;
}
#ifdef USE_CURL_MULTI
---
0.99.8.GIT
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-21 19:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-21 19:06 [PATCH 1/3] Clean up CURL handles in unused request slots Nick Hengeveld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).