summaryrefslogtreecommitdiff
path: root/pack-objects.h
diff options
context:
space:
mode:
authorPatrick Hogg <phogg@novamoon.net>2019-01-25 00:22:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-28 19:22:06 (GMT)
commit459307b139c9a859ca0b6ca5276cf9be3d2b8e3e (patch)
tree8ca32b5889cf2278a5269a73fd3521f2869747af /pack-objects.h
parent0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff)
downloadgit-459307b139c9a859ca0b6ca5276cf9be3d2b8e3e.zip
git-459307b139c9a859ca0b6ca5276cf9be3d2b8e3e.tar.gz
git-459307b139c9a859ca0b6ca5276cf9be3d2b8e3e.tar.bz2
pack-objects: move read mutex to packing_data struct
ac77d0c37 ("pack-objects: shrink size field in struct object_entry", 2018-04-14) added an extra usage of read_lock/read_unlock in the newly introduced oe_get_size_slow for thread safety in parallel calls to try_delta(). Unfortunately oe_get_size_slow is also used in serial code, some of which is called before the first invocation of ll_find_deltas. As such the read mutex is not guaranteed to be initialized. Resolve this by moving the read mutex to packing_data and initializing it in prepare_packing_data which is initialized in cmd_pack_objects. Signed-off-by: Patrick Hogg <phogg@novamoon.net> Reviewed-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-objects.h')
-rw-r--r--pack-objects.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/pack-objects.h b/pack-objects.h
index dc869f2..0a038e3 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -146,6 +146,7 @@ struct packing_data {
struct packed_git **in_pack;
pthread_mutex_t lock;
+ pthread_mutex_t read_lock;
/*
* This list contains entries for bases which we know the other side
@@ -174,6 +175,15 @@ static inline void packing_data_unlock(struct packing_data *pdata)
pthread_mutex_unlock(&pdata->lock);
}
+static inline void packing_data_read_lock(struct packing_data *pdata)
+{
+ pthread_mutex_lock(&pdata->read_lock);
+}
+static inline void packing_data_read_unlock(struct packing_data *pdata)
+{
+ pthread_mutex_unlock(&pdata->read_lock);
+}
+
struct object_entry *packlist_alloc(struct packing_data *pdata,
const unsigned char *sha1,
uint32_t index_pos);