Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Sat, 29 Aug 2009 02:37:57 +0000 (19:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 29 Aug 2009 02:37:57 +0000 (19:37 -0700)
* maint:
http.c: set slot callback members to NULL when releasing object

1  2 
http.c
diff --combined http.c
index eb0c6698013e717eda5b6005fb48666191238aab,d60f7f7679459fe5e5ce64daf7152bd83535b632..5926c5b3f7bbc781d77e2348db2990bcb51460e6
--- 1/http.c
--- 2/http.c
+++ b/http.c
@@@ -1006,6 -1006,7 +1006,6 @@@ int finish_http_pack_request(struct htt
  struct http_pack_request *new_http_pack_request(
        struct packed_git *target, const char *base_url)
  {
 -      char *url;
        char *filename;
        long prev_posn = 0;
        char range[RANGE_HEADER_SIZE];
        end_url_with_slash(&buf, base_url);
        strbuf_addf(&buf, "objects/pack/pack-%s.pack",
                sha1_to_hex(target->sha1));
 -      url = strbuf_detach(&buf, NULL);
 -      preq->url = xstrdup(url);
 +      preq->url = strbuf_detach(&buf, NULL);
  
        filename = sha1_pack_name(target->sha1);
        snprintf(preq->filename, sizeof(preq->filename), "%s", filename);
        preq->slot->local = preq->packfile;
        curl_easy_setopt(preq->slot->curl, CURLOPT_FILE, preq->packfile);
        curl_easy_setopt(preq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
 -      curl_easy_setopt(preq->slot->curl, CURLOPT_URL, url);
 +      curl_easy_setopt(preq->slot->curl, CURLOPT_URL, preq->url);
        curl_easy_setopt(preq->slot->curl, CURLOPT_HTTPHEADER,
                no_pragma_header);
  
  
  abort:
        free(filename);
 +      free(preq->url);
 +      free(preq);
        return NULL;
  }
  
@@@ -1100,6 -1100,7 +1100,6 @@@ struct http_object_request *new_http_ob
        char *hex = sha1_to_hex(sha1);
        char *filename;
        char prevfile[PATH_MAX];
 -      char *url;
        int prevlocal;
        unsigned char prev_buf[PREV_BUF_SIZE];
        ssize_t prev_read = 0;
  
        git_SHA1_Init(&freq->c);
  
 -      url = get_remote_object_url(base_url, hex, 0);
 -      freq->url = xstrdup(url);
 +      freq->url = get_remote_object_url(base_url, hex, 0);
  
        /*
         * If a previous temp file is present, process what was already
                if (prev_posn>0) {
                        prev_posn = 0;
                        lseek(freq->localfile, 0, SEEK_SET);
 -                      ftruncate(freq->localfile, 0);
 +                      if (ftruncate(freq->localfile, 0) < 0) {
 +                              error("Couldn't truncate temporary file %s for %s: %s",
 +                                        freq->tmpfile, freq->filename, strerror(errno));
 +                              goto abort;
 +                      }
                }
        }
  
        curl_easy_setopt(freq->slot->curl, CURLOPT_FILE, freq);
        curl_easy_setopt(freq->slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
        curl_easy_setopt(freq->slot->curl, CURLOPT_ERRORBUFFER, freq->errorstr);
 -      curl_easy_setopt(freq->slot->curl, CURLOPT_URL, url);
 +      curl_easy_setopt(freq->slot->curl, CURLOPT_URL, freq->url);
        curl_easy_setopt(freq->slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
  
        /*
  
        return freq;
  
 -      free(url);
  abort:
        free(filename);
 +      free(freq->url);
        free(freq);
        return NULL;
  }
@@@ -1289,5 -1287,10 +1289,10 @@@ void release_http_object_request(struc
                free(freq->url);
                freq->url = NULL;
        }
-       freq->slot = NULL;
+       if (freq->slot != NULL) {
+               freq->slot->callback_func = NULL;
+               freq->slot->callback_data = NULL;
+               release_active_slot(freq->slot);
+               freq->slot = NULL;
+       }
  }