- while (request->state == ACTIVE) {
- run_active_slot(request->slot);
-#ifndef USE_CURL_MULTI
- request->curl_result = request->slot->curl_result;
- curl_easy_getinfo(request->slot->curl,
- CURLINFO_HTTP_CODE,
- &request->http_code);
- request->slot = NULL;
-
- /* Use alternates if necessary */
- if (request->http_code == 404 &&
- request->repo->next != NULL) {
- request->repo = request->repo->next;
- start_request(request);
- } else {
- finish_request(request);
- request->state = COMPLETE;
- }
-#endif
- }
-
- if (request->state == ABORTED) {
- release_request(request);
- return error("Request for %s aborted", hex);
- }
-
- if (request->curl_result != CURLE_OK && request->http_code != 416) {
- ret = error("%s", request->errorstr);
- release_request(request);
- return ret;
- }
-
- if (request->zret != Z_STREAM_END) {
- ret = error("File %s (%s) corrupt\n", hex, request->url);
- release_request(request);
- return ret;
- }
-
- if (memcmp(request->sha1, request->real_sha1, 20)) {
- release_request(request);
- return error("File %s has bad hash\n", hex);
- }
-
- if (request->rename < 0) {
- ret = error("unable to write sha1 filename %s: %s",
- request->filename,
- strerror(request->rename));
- release_request(request);
- return ret;
- }
-
- release_request(request);
- return 0;
+ while (obj_req->state == ACTIVE) {
+ run_active_slot(obj_req->slot);
+ }
+ if (obj_req->local != -1) {
+ close(obj_req->local); obj_req->local = -1;
+ }
+
+ if (obj_req->state == ABORTED) {
+ ret = error("Request for %s aborted", hex);
+ } else if (obj_req->curl_result != CURLE_OK &&
+ obj_req->http_code != 416) {
+ if (obj_req->http_code == 404 ||
+ obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
+ ret = -1; /* Be silent, it is probably in a pack. */
+ else
+ ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
+ obj_req->errorstr, obj_req->curl_result,
+ obj_req->http_code, hex);
+ } else if (obj_req->zret != Z_STREAM_END) {
+ corrupt_object_found++;
+ ret = error("File %s (%s) corrupt", hex, obj_req->url);
+ } else if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
+ ret = error("File %s has bad hash", hex);
+ } else if (obj_req->rename < 0) {
+ ret = error("unable to write sha1 filename %s",
+ obj_req->filename);
+ }
+
+ release_object_request(obj_req);
+ return ret;