summaryrefslogtreecommitdiff
path: root/builtin/index-pack.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2013-03-19 14:16:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-03-19 15:40:47 (GMT)
commit8f82aad4e7baf32942eb2087a882e0f8646b2da8 (patch)
tree201c0298e81b948a37fb98ccfaf00b27214fba98 /builtin/index-pack.c
parent3aba2fddcbff6ba611c05eabeb4a8561c119275f (diff)
downloadgit-8f82aad4e7baf32942eb2087a882e0f8646b2da8.zip
git-8f82aad4e7baf32942eb2087a882e0f8646b2da8.tar.gz
git-8f82aad4e7baf32942eb2087a882e0f8646b2da8.tar.bz2
index-pack: guard nr_resolved_deltas reads by lock
The threaded parts of index-pack increment the number of resolved deltas in nr_resolved_deltas guarded by counter_mutex. However, the per-thread outer loop accessed nr_resolved_deltas without any locks. This is not wrong as such, since it doesn't matter all that much whether we get an outdated value. However, unless someone proves that this one lock makes all the performance difference, it would be much cleaner to guard _all_ accesses to the variable with the lock. The only such use is display_progress() in the threaded section (all others are in the conclude_pack() callchain outside the threaded part). To make it obvious that it cannot deadlock, move it out of work_mutex. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/index-pack.c')
-rw-r--r--builtin/index-pack.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 8fe9df5..fe63cff 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -967,8 +967,10 @@ static void *threaded_second_pass(void *data)
set_thread_data(data);
for (;;) {
int i;
- work_lock();
+ counter_lock();
display_progress(progress, nr_resolved_deltas);
+ counter_unlock();
+ work_lock();
while (nr_dispatched < nr_objects &&
is_delta_type(objects[nr_dispatched].type))
nr_dispatched++;