Skip to content

Commit 68e6a4f

Browse files
Johannes Sixtgitster
authored andcommitted
Plug a resource leak in threaded pack-objects code.
A mutex and a condition variable is allocated for each thread and torn down when the thread terminates. However, for certain workloads it can happen that some threads are actually not started at all. In this case we would leak the mutex and condition variable. Now we allocate them only for those threads that are actually started. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6fbe42c commit 68e6a4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin-pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,8 +1670,6 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
16701670
p[i].processed = processed;
16711671
p[i].working = 1;
16721672
p[i].data_ready = 0;
1673-
pthread_mutex_init(&p[i].mutex, NULL);
1674-
pthread_cond_init(&p[i].cond, NULL);
16751673

16761674
/* try to split chunks on "path" boundaries */
16771675
while (sub_size < list_size && list[sub_size]->hash &&
@@ -1690,6 +1688,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
16901688
for (i = 0; i < delta_search_threads; i++) {
16911689
if (!p[i].list_size)
16921690
continue;
1691+
pthread_mutex_init(&p[i].mutex, NULL);
1692+
pthread_cond_init(&p[i].cond, NULL);
16931693
ret = pthread_create(&p[i].thread, NULL,
16941694
threaded_find_deltas, &p[i]);
16951695
if (ret)

0 commit comments

Comments
 (0)