Skip to content

Commit 8f82aad

Browse files
trastgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3aba2fd commit 8f82aad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/index-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,10 @@ static void *threaded_second_pass(void *data)
967967
set_thread_data(data);
968968
for (;;) {
969969
int i;
970-
work_lock();
970+
counter_lock();
971971
display_progress(progress, nr_resolved_deltas);
972+
counter_unlock();
973+
work_lock();
972974
while (nr_dispatched < nr_objects &&
973975
is_delta_type(objects[nr_dispatched].type))
974976
nr_dispatched++;

0 commit comments

Comments
 (0)