Merge branch 'rc/maint-http-local-slot-fix'

* rc/maint-http-local-slot-fix:
  http*: cleanup slot->local after fclose
This commit is contained in:
Junio C Hamano 2009-06-13 12:51:09 -07:00
commit fa71e80525
2 changed files with 12 additions and 0 deletions

View file

@ -724,9 +724,11 @@ static void finish_request(struct transfer_request *request)
struct stat st; struct stat st;
struct packed_git *target; struct packed_git *target;
struct packed_git **lst; struct packed_git **lst;
struct active_request_slot *slot;
request->curl_result = request->slot->curl_result; request->curl_result = request->slot->curl_result;
request->http_code = request->slot->http_code; request->http_code = request->slot->http_code;
slot = request->slot;
request->slot = NULL; request->slot = NULL;
/* Keep locks active */ /* Keep locks active */
@ -823,6 +825,7 @@ static void finish_request(struct transfer_request *request)
fclose(request->local_stream); fclose(request->local_stream);
request->local_stream = NULL; request->local_stream = NULL;
slot->local = NULL;
if (!move_temp_to_file(request->tmpfile, if (!move_temp_to_file(request->tmpfile,
request->filename)) { request->filename)) {
target = (struct packed_git *)request->userData; target = (struct packed_git *)request->userData;
@ -1024,17 +1027,20 @@ static int fetch_index(unsigned char *sha1)
if (results.curl_result != CURLE_OK) { if (results.curl_result != CURLE_OK) {
free(url); free(url);
fclose(indexfile); fclose(indexfile);
slot->local = NULL;
return error("Unable to get pack index %s\n%s", url, return error("Unable to get pack index %s\n%s", url,
curl_errorstr); curl_errorstr);
} }
} else { } else {
free(url); free(url);
fclose(indexfile); fclose(indexfile);
slot->local = NULL;
return error("Unable to start request"); return error("Unable to start request");
} }
free(url); free(url);
fclose(indexfile); fclose(indexfile);
slot->local = NULL;
return move_temp_to_file(tmpfile, filename); return move_temp_to_file(tmpfile, filename);
} }

View file

@ -418,15 +418,18 @@ static int fetch_index(struct walker *walker, struct alt_base *repo, unsigned ch
run_active_slot(slot); run_active_slot(slot);
if (results.curl_result != CURLE_OK) { if (results.curl_result != CURLE_OK) {
fclose(indexfile); fclose(indexfile);
slot->local = NULL;
return error("Unable to get pack index %s\n%s", url, return error("Unable to get pack index %s\n%s", url,
curl_errorstr); curl_errorstr);
} }
} else { } else {
fclose(indexfile); fclose(indexfile);
slot->local = NULL;
return error("Unable to start request"); return error("Unable to start request");
} }
fclose(indexfile); fclose(indexfile);
slot->local = NULL;
return move_temp_to_file(tmpfile, filename); return move_temp_to_file(tmpfile, filename);
} }
@ -776,16 +779,19 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha
run_active_slot(slot); run_active_slot(slot);
if (results.curl_result != CURLE_OK) { if (results.curl_result != CURLE_OK) {
fclose(packfile); fclose(packfile);
slot->local = NULL;
return error("Unable to get pack file %s\n%s", url, return error("Unable to get pack file %s\n%s", url,
curl_errorstr); curl_errorstr);
} }
} else { } else {
fclose(packfile); fclose(packfile);
slot->local = NULL;
return error("Unable to start request"); return error("Unable to start request");
} }
target->pack_size = ftell(packfile); target->pack_size = ftell(packfile);
fclose(packfile); fclose(packfile);
slot->local = NULL;
ret = move_temp_to_file(tmpfile, filename); ret = move_temp_to_file(tmpfile, filename);
if (ret) if (ret)