[PATCH] squash! grep: replace grep_read_mutex by internal obj read lock
- From
Matheus Tavares <matheus.bernardino@usp.br>
- Date
- Oct 1, 2019, 19:23 UTC
- Message-ID
- <e452947091b96a02ca3292f8cd9793a8d661fca4.1569950899.git.matheus.bernardino@usp.br>
- In-Reply-To
- <48b632d7a0278f4abb4f0b0390f316a631a9d0ef.1569808052.git.matheus.bernardino@usp.br>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> ---
This is just a small fixup to be squashed into patch 6: with multiple locks, the locking order must be consistent across all critical sections to avoid dead-lock. Since grep_attr_lock() is called before obj_read_lock() in grep_source_load_driver(), it must also be called first here.
grep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grep.c b/grep.c index 0ca400f7b6..85ee89b5d6 100644 --- a/grep.c +++ b/grep.c @@ -1813,11 +1813,11 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle * currenty thread-safe and might be racy with object reading, * obj_read_lock() must be called. */ - obj_read_lock(); grep_attr_lock(); + obj_read_lock(); textconv = userdiff_get_textconv(opt->repo, gs->driver); - grep_attr_unlock(); obj_read_unlock(); + grep_attr_unlock(); } /*
-- 2.23.0