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

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

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Feb 15, 2010, 22:50 UTC
Message-ID
<20100215225001.GA944@book.hvoigt.net>

In case the machine has only one cpu the initialization was skipped.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
 builtin-grep.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index 26d4deb..644051c 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -220,12 +220,6 @@ static void start_threads(struct grep_opt *opt)
 {
 	int i;
 
-	pthread_mutex_init(&grep_mutex, NULL);
-	pthread_mutex_init(&read_sha1_mutex, NULL);
-	pthread_cond_init(&cond_add, NULL);
-	pthread_cond_init(&cond_write, NULL);
-	pthread_cond_init(&cond_result, NULL);
-
 	for (i = 0; i < ARRAY_SIZE(todo); i++) {
 		strbuf_init(&todo[i].out, 0);
 	}
@@ -880,6 +874,12 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	if (online_cpus() == 1 || !grep_threads_ok(&opt))
 		use_threads = 0;
 
+	pthread_mutex_init(&grep_mutex, NULL);
+	pthread_mutex_init(&read_sha1_mutex, NULL);
+	pthread_cond_init(&cond_add, NULL);
+	pthread_cond_init(&cond_write, NULL);
+	pthread_cond_init(&cond_result, NULL);
+
 	if (use_threads)
 		start_threads(&opt);
 #else
-- 
1.7.0.rc1.7.gc0da5
Next: Johannes Schindelin
Message 1 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.