{"thread":{"id":"2598","subject":"[PATCH 5/5] http-push memory/fd cleanup","startedAt":"2005-11-18T19:03:25Z","lastAt":"2005-11-18T19:03:25Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"12271","messageId":"20051118190324.GJ3968@reactrix.com","threadId":"2598","inReplyTo":null,"subject":"[PATCH 5/5] http-push memory/fd cleanup","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2005-11-18T19:03:25Z","receivedAt":"2005-11-18T19:03:25Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"Clean up memory and file descriptor usage\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\n http-push.c |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\napplies-to: 697c3fa609568c3befb803dd8a131814ca1fad6a\n898a8d2e69916757f423a8bd487d97f19c06c1e0\ndiff --git a/http-push.c b/http-push.c\nindex 2932693..f3c92c9 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -165,6 +165,7 @@ static void start_check(struct transfer_\n \t} else {\n \t\trequest->state = ABORTED;\n \t\tfree(request->url);\n+\t\trequest->url = NULL;\n \t}\n }\n \n@@ -198,6 +199,7 @@ static void start_mkcol(struct transfer_\n \t} else {\n \t\trequest->state = ABORTED;\n \t\tfree(request->url);\n+\t\trequest->url = NULL;\n \t}\n }\n \n@@ -244,8 +246,6 @@ static void start_put(struct transfer_re\n \trequest->buffer.size = stream.total_out;\n \trequest->buffer.posn = 0;\n \n-\tif (request->url != NULL)\n-\t\tfree(request->url);\n \trequest->url = xmalloc(strlen(remote->url) + \n \t\t\t       strlen(request->lock->token) + 51);\n \tstrcpy(request->url, remote->url);\n@@ -281,6 +281,7 @@ static void start_put(struct transfer_re\n \t} else {\n \t\trequest->state = ABORTED;\n \t\tfree(request->url);\n+\t\trequest->url = NULL;\n \t}\n }\n \n@@ -306,6 +307,7 @@ static void start_move(struct transfer_r\n \t} else {\n \t\trequest->state = ABORTED;\n \t\tfree(request->url);\n+\t\trequest->url = NULL;\n \t}\n }\n \n@@ -370,6 +372,13 @@ static void finish_request(struct transf\n \n \tif (request->headers != NULL)\n \t\tcurl_slist_free_all(request->headers);\n+\n+\t/* URL is reused for MOVE after PUT */\n+\tif (request->state != RUN_PUT) {\n+\t\tfree(request->url);\n+\t\trequest->url = NULL;\n+\t}\t\t\n+\n \tif (request->state == RUN_HEAD) {\n \t\tif (request->http_code == 404) {\n \t\t\trequest->state = NEED_PUSH;\n@@ -435,7 +444,8 @@ static void release_request(struct trans\n \t\t\tentry->next = entry->next->next;\n \t}\n \n-\tfree(request->url);\n+\tif (request->url != NULL)\n+\t\tfree(request->url);\n \tfree(request);\n }\n \n@@ -575,6 +585,7 @@ static int fetch_index(unsigned char *sh\n \t\t}\n \t} else {\n \t\tfree(url);\n+\t\tfclose(indexfile);\n \t\treturn error(\"Unable to start request\");\n \t}\n \n---\n0.99.9.GIT\n"}]}