diff options
| author | Alan Rogers <alan@github.com> | 2014-07-22 15:08:24 +1000 |
|---|---|---|
| committer | Alan Rogers <alan@github.com> | 2014-07-22 15:08:24 +1000 |
| commit | 7d0ab0fae04015e0bc66ff16beae495f13969b10 (patch) | |
| tree | 09323e451046ef9dfa6f83754c3fe1fb3d327b48 /src/indexer.c | |
| parent | e824e63de6724557946ba155034ff8c864f594d2 (diff) | |
| parent | 091165c53b2bcd5d41fb71d43ed5a23a3d96bf5d (diff) | |
| download | libgit2-7d0ab0fae04015e0bc66ff16beae495f13969b10.tar.gz | |
Merge remote-tracking branch 'origin/master' into fix-git-status-list-new-unreadable-folder
Diffstat (limited to 'src/indexer.c')
| -rw-r--r-- | src/indexer.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/indexer.c b/src/indexer.c index 25c3d0537..010de329b 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -18,6 +18,8 @@ #include "oidmap.h" #include "zstream.h" +extern git_mutex git__mwindow_mutex; + #define UINT31_MAX (0x7FFFFFFF) struct entry { @@ -433,6 +435,8 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t git_map map; int error; + assert(data && size); + /* the offset needs to be at the beginning of the a page boundary */ page_start = (offset / page_size) * page_size; page_offset = offset - page_start; @@ -451,9 +455,12 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size) { git_off_t current_size = idx->pack->mwf.size; + if (!size) + return 0; + /* add the extra space we need at the end */ if (p_ftruncate(idx->pack->mwf.fd, current_size + size) < 0) { - giterr_system_set(errno); + giterr_set(GITERR_OS, "Failed to increase size of pack file '%s'", idx->pack->pack_name); return -1; } @@ -1044,6 +1051,11 @@ void git_indexer_free(git_indexer *idx) } git_vector_free_deep(&idx->deltas); - git_packfile_free(idx->pack); + + if (!git_mutex_lock(&git__mwindow_mutex)) { + git_packfile_free(idx->pack); + git_mutex_unlock(&git__mwindow_mutex); + } + git__free(idx); } |
