Re: [PATCH/RFC] grep: turn off threading when recursing submodules
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Oct 19, 2017, 19:50 UTC
- Message-ID
- <CAN0heSpxJDxmSXu=P0stq+CsKVqjsvOnjDpOoMT9GdWxeZU2Pw@mail.gmail.com>
- In-Reply-To
- <20171019193413.prx5pkmwaxk6mpdt@sigill.intra.peff.net>
On 19 October 2017 at 21:34, Jeff King <peff@peff.net> wrote:
Show 17 quoted lines
> On Thu, Oct 19, 2017 at 12:26:18PM -0700, Brandon Williams wrote: > >> One alternative to turning off threading would be to employ proper >> locking (like I failed to do) by wrapping the call the >> 'add_to_alternates_memory()' in calls to grep_read_lock/unlock: >> >> + grep_read_lock(); >> add_to_alternates_memory(submodule.objectdir); >> + grep_read_unlock(); >> >> That way adding the submodule to the object database won't happen at the >> same time another thread is trying to read from the object store. > > Yeah, I think that is the right approach. Many of Git's APIs aren't > thread-safe, so we need a big mutex around "I am doing anything except > actually looking at the already-read blob contents". We just missed this > spot.
That's a big glaring lock I missed, right in front of me. Looks like the right solution!