From: Junio C Hamano Date: Mon, 22 Jun 2009 04:15:31 +0000 (-0700) Subject: Merge branch 'rc/maint-http-local-slot-fix' into maint X-Git-Tag: v1.6.3.3~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/be273c73b72b67154eae7ce4f3ad66098a7f8f47?hp=-c Merge branch 'rc/maint-http-local-slot-fix' into maint * rc/maint-http-local-slot-fix: http*: cleanup slot->local after fclose --- be273c73b72b67154eae7ce4f3ad66098a7f8f47 diff --combined http-push.c index e16a0ad3f9,673a61110e..0b12ffe18f --- a/http-push.c +++ b/http-push.c @@@ -315,9 -315,9 +315,9 @@@ static void start_fetch_loose(struct tr "%s.temp", filename); snprintf(prevfile, sizeof(prevfile), "%s.prev", request->filename); - unlink(prevfile); + unlink_or_warn(prevfile); rename(request->tmpfile, prevfile); - unlink(request->tmpfile); + unlink_or_warn(request->tmpfile); if (request->local_fileno != -1) error("fd leakage in start: %d", request->local_fileno); @@@ -372,7 -372,7 +372,7 @@@ } while (prev_read > 0); close(prevlocal); } - unlink(prevfile); + unlink_or_warn(prevfile); /* Reset inflate/SHA1 if there was an error reading the previous temp file; also rewind to the beginning of the local file. */ @@@ -724,9 -724,11 +724,11 @@@ static void finish_request(struct trans struct stat st; struct packed_git *target; struct packed_git **lst; + struct active_request_slot *slot; request->curl_result = request->slot->curl_result; request->http_code = request->slot->http_code; + slot = request->slot; request->slot = NULL; /* Keep locks active */ @@@ -784,7 -786,7 +786,7 @@@ request->http_code != 416) { if (stat(request->tmpfile, &st) == 0) { if (st.st_size == 0) - unlink(request->tmpfile); + unlink_or_warn(request->tmpfile); } } else { if (request->http_code == 416) @@@ -793,9 -795,9 +795,9 @@@ git_inflate_end(&request->stream); git_SHA1_Final(request->real_sha1, &request->c); if (request->zret != Z_STREAM_END) { - unlink(request->tmpfile); + unlink_or_warn(request->tmpfile); } else if (hashcmp(request->obj->sha1, request->real_sha1)) { - unlink(request->tmpfile); + unlink_or_warn(request->tmpfile); } else { request->rename = move_temp_to_file( @@@ -823,6 -825,7 +825,7 @@@ fclose(request->local_stream); request->local_stream = NULL; + slot->local = NULL; if (!move_temp_to_file(request->tmpfile, request->filename)) { target = (struct packed_git *)request->userData; @@@ -1024,17 -1027,20 +1027,20 @@@ static int fetch_index(unsigned char *s if (results.curl_result != CURLE_OK) { free(url); fclose(indexfile); + slot->local = NULL; return error("Unable to get pack index %s\n%s", url, curl_errorstr); } } else { free(url); fclose(indexfile); + slot->local = NULL; return error("Unable to start request"); } free(url); fclose(indexfile); + slot->local = NULL; return move_temp_to_file(tmpfile, filename); } @@@ -1415,9 -1421,8 +1421,9 @@@ static void remove_locks(void fprintf(stderr, "Removing remote locks...\n"); while (lock) { + struct remote_lock *next = lock->next; unlock_remote(lock); - lock = lock->next; + lock = next; } } diff --combined http-walker.c index 7321ccc9fe,ec1c97f2ee..9377851925 --- a/http-walker.c +++ b/http-walker.c @@@ -111,9 -111,9 +111,9 @@@ static void start_object_request(struc struct walker_data *data = walker->data; snprintf(prevfile, sizeof(prevfile), "%s.prev", obj_req->filename); - unlink(prevfile); + unlink_or_warn(prevfile); rename(obj_req->tmpfile, prevfile); - unlink(obj_req->tmpfile); + unlink_or_warn(obj_req->tmpfile); if (obj_req->local != -1) error("fd leakage in start: %d", obj_req->local); @@@ -177,7 -177,7 +177,7 @@@ } while (prev_read > 0); close(prevlocal); } - unlink(prevfile); + unlink_or_warn(prevfile); /* Reset inflate/SHA1 if there was an error reading the previous temp file; also rewind to the beginning of the local file. */ @@@ -238,18 -238,18 +238,18 @@@ static void finish_object_request(struc } else if (obj_req->curl_result != CURLE_OK) { if (stat(obj_req->tmpfile, &st) == 0) if (st.st_size == 0) - unlink(obj_req->tmpfile); + unlink_or_warn(obj_req->tmpfile); return; } git_inflate_end(&obj_req->stream); git_SHA1_Final(obj_req->real_sha1, &obj_req->c); if (obj_req->zret != Z_STREAM_END) { - unlink(obj_req->tmpfile); + unlink_or_warn(obj_req->tmpfile); return; } if (hashcmp(obj_req->sha1, obj_req->real_sha1)) { - unlink(obj_req->tmpfile); + unlink_or_warn(obj_req->tmpfile); return; } obj_req->rename = @@@ -418,15 -418,18 +418,18 @@@ static int fetch_index(struct walker *w run_active_slot(slot); if (results.curl_result != CURLE_OK) { fclose(indexfile); + slot->local = NULL; return error("Unable to get pack index %s\n%s", url, curl_errorstr); } } else { fclose(indexfile); + slot->local = NULL; return error("Unable to start request"); } fclose(indexfile); + slot->local = NULL; return move_temp_to_file(tmpfile, filename); } @@@ -776,16 -779,19 +779,19 @@@ static int fetch_pack(struct walker *wa run_active_slot(slot); if (results.curl_result != CURLE_OK) { fclose(packfile); + slot->local = NULL; return error("Unable to get pack file %s\n%s", url, curl_errorstr); } } else { fclose(packfile); + slot->local = NULL; return error("Unable to start request"); } target->pack_size = ftell(packfile); fclose(packfile); + slot->local = NULL; ret = move_temp_to_file(tmpfile, filename); if (ret) @@@ -809,7 -815,7 +815,7 @@@ static void abort_object_request(struc close(obj_req->local); obj_req->local = -1; } - unlink(obj_req->tmpfile); + unlink_or_warn(obj_req->tmpfile); if (obj_req->slot) { release_active_slot(obj_req->slot); obj_req->slot = NULL;