summaryrefslogtreecommitdiff
path: root/COPYING
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2012-02-02 03:18:29 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-02-02 10:36:07 -0800
commit78db6ea9dc1a872f9d07a36fe7aec700a5c963b9 (patch)
tree9dd1308cd344c12239a17a698355c836e49c7200 /COPYING
parentGit 1.7.9 (diff)
downloadtgif-78db6ea9dc1a872f9d07a36fe7aec700a5c963b9.tar.xz
grep: make locking flag global
The low-level grep code traditionally didn't care about threading, as it doesn't do any threading itself and didn't call out to other non-thread-safe code. That changed with 0579f91 (grep: enable threading with -p and -W using lazy attribute lookup, 2011-12-12), which pushed the lookup of funcname attributes (which is not thread-safe) into the low-level grep code. As a result, the low-level code learned about a new global "grep_attr_mutex" to serialize access to the attribute code. A multi-threaded caller (e.g., builtin/grep.c) is expected to initialize the mutex and set "use_threads" in the grep_opt structure. The low-level code only uses the lock if use_threads is set. However, putting the use_threads flag into the grep_opt struct is not the most logical place. Whether threading is in use is not something that matters for each call to grep_buffer, but is instead global to the whole program (i.e., if any thread is doing multi-threaded grep, every other thread, even if it thinks it is doing its own single-threaded grep, would need to use the locking). In practice, this distinction isn't a problem for us, because the only user of multi-threaded grep is "git-grep", which does nothing except call grep. This patch turns the opt->use_threads flag into a global flag. More important than the nit-picking semantic argument above is that this means that the locking functions don't need to actually have access to a grep_opt to know whether to lock. Which in turn can make adding new locks simpler, as we don't need to pass around a grep_opt. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'COPYING')
0 files changed, 0 insertions, 0 deletions