git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix threaded grep for machines with only one cpu
@ 2010-02-15 22:50 Heiko Voigt
  2010-02-15 23:09 ` Johannes Schindelin
  2010-02-16  1:07 ` Junio C Hamano
  0 siblings, 2 replies; 26+ messages in thread
From: Heiko Voigt @ 2010-02-15 22:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin

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

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2010-02-18  9:04 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-15 22:50 [PATCH] fix threaded grep for machines with only one cpu Heiko Voigt
2010-02-15 23:09 ` Johannes Schindelin
2010-02-16  1:07 ` Junio C Hamano
2010-02-16  1:12   ` Junio C Hamano
2010-02-16  2:32   ` Junio C Hamano
2010-02-16  2:39     ` Junio C Hamano
2010-02-16  7:54       ` Fredrik Kuivinen
2010-02-16  8:15       ` Johannes Schindelin
2010-02-16 23:59         ` Junio C Hamano
2010-02-17  1:01           ` Johannes Schindelin
2010-02-17  1:26             ` Junio C Hamano
2010-02-17  2:41               ` Nicolas Pitre
2010-02-17 22:43           ` Heiko Voigt
2010-02-18  9:10             ` Johannes Schindelin
2010-02-16 18:02       ` Heiko Voigt
2010-02-16 18:59         ` Nicolas Pitre
2010-02-16 19:20         ` Junio C Hamano
2010-02-16 19:26           ` Sverre Rabbelier
2010-02-16 20:00           ` Nicolas Pitre
2010-02-16 20:19             ` Johannes Schindelin
2010-02-16 20:37               ` Nicolas Pitre
2010-02-16 20:57             ` Heiko Voigt
2010-02-16 21:20               ` Nicolas Pitre
2010-02-16 22:54                 ` Junio C Hamano
2010-02-17 17:56                   ` Heiko Voigt
2010-02-17 15:29             ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).