git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fix threaded grep for machines with only one cpu

From
Fredrik Kuivinen <frekui@gmail.com>
Date
Feb 16, 2010, 07:54 UTC
Message-ID
<4c8ef71002152354s3be9503aja28e5426a735ca07@mail.gmail.com>
In-Reply-To
<7vljetlx8r.fsf@alter.siamese.dyndns.org>
On Tue, Feb 16, 2010 at 03:39, Junio C Hamano <gitster@pobox.com> wrote:
Show 37 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Is this the answer to my question?
>
> IOW, please try this patch.  I am planning to queue it to 'maint' as part
> of 1.7.0.1 if this is the right solution (which I obviously think it is).
>
> -- >8 --
> From: Junio C Hamano <gitster@pobox.com>
> Date: Mon, 15 Feb 2010 18:34:28 -0800
> Subject: [PATCH] Fix use of mutex in threaded grep
>
> The program can decide at runtime not to use threading even if the
> support is compiled in.  In such a case, mutexes are not necessary
> and left uninitialized.  But the code incorrectly tried to take and
> release the read_sha1_mutex unconditionally.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin-grep.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin-grep.c b/builtin-grep.c
> index 26d4deb..5c1545e 100644
> --- a/builtin-grep.c
> +++ b/builtin-grep.c
> @@ -81,8 +81,8 @@ static pthread_mutex_t read_sha1_mutex;
>
>  #define grep_lock() pthread_mutex_lock(&grep_mutex)
>  #define grep_unlock() pthread_mutex_unlock(&grep_mutex)
> -#define read_sha1_lock() pthread_mutex_lock(&read_sha1_mutex)
> -#define read_sha1_unlock() pthread_mutex_unlock(&read_sha1_mutex)
> +#define read_sha1_lock() do { if (use_threads) pthread_mutex_lock(&read_sha1_mutex); } while (0)
> +#define read_sha1_unlock() do { if (use_threads) pthread_mutex_unlock(&read_sha1_mutex); } while (0)
>
>  /* Signalled when a new work_item is added to todo. */
>  static pthread_cond_t cond_add;
This is the correct fix. Thanks.
Acked-by: Fredrik Kuivinen <frekui@gmail.com>
- Fredrik
Previous: Junio C HamanoNext: Johannes Schindelin
Message 7 of 26 in “fix threaded grep for machines with only one cpu”
  1. fix threaded grep for machines with only one cpuHeiko Voigt, Feb 15, 2010
  2. Johannes SchindelinFeb 15, 2010
  3. Junio C HamanoFeb 16, 2010
  4. Junio C HamanoFeb 16, 2010
  5. Junio C HamanoFeb 16, 2010
  6. Junio C HamanoFeb 16, 2010
  7. Fredrik KuivinenFeb 16, 2010
  8. Johannes SchindelinFeb 16, 2010
  9. Junio C HamanoFeb 16, 2010
  10. Johannes SchindelinFeb 17, 2010
  11. Junio C HamanoFeb 17, 2010
  12. Nicolas PitreFeb 17, 2010
  13. Heiko VoigtFeb 17, 2010
  14. Johannes SchindelinFeb 18, 2010
  15. Heiko VoigtFeb 16, 2010
  16. Nicolas PitreFeb 16, 2010
  17. Junio C HamanoFeb 16, 2010
  18. Sverre RabbelierFeb 16, 2010
  19. Nicolas PitreFeb 16, 2010
  20. Johannes SchindelinFeb 16, 2010
  21. Nicolas PitreFeb 16, 2010
  22. Heiko VoigtFeb 16, 2010
  23. Nicolas PitreFeb 16, 2010
  24. Junio C HamanoFeb 16, 2010
  25. Heiko VoigtFeb 17, 2010
  26. Paolo BonziniFeb 17, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.