From e8d405662fa2e89b850ec79573953e17fea83ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 3 Nov 2018 09:48:45 +0100 Subject: preload-index.c: remove #ifdef NO_PTHREADS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- preload-index.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'preload-index.c') diff --git a/preload-index.c b/preload-index.c index 9e7152ab14..0e24886aca 100644 --- a/preload-index.c +++ b/preload-index.c @@ -7,17 +7,7 @@ #include "fsmonitor.h" #include "config.h" #include "progress.h" - -#ifdef NO_PTHREADS -static void preload_index(struct index_state *index, - const struct pathspec *pathspec, - unsigned int refresh_flags) -{ - ; /* nothing */ -} -#else - -#include +#include "thread-utils.h" /* * Mostly randomly chosen maximum thread counts: we @@ -108,7 +98,7 @@ static void preload_index(struct index_state *index, struct thread_data data[MAX_PARALLEL]; struct progress_data pd; - if (!core_preload_index) + if (!HAVE_THREADS || !core_preload_index) return; threads = index->cache_nr / THREAD_COST; @@ -151,7 +141,6 @@ static void preload_index(struct index_state *index, trace_performance_leave("preload index"); } -#endif int read_index_preload(struct index_state *index, const struct pathspec *pathspec, -- cgit v1.2.3 From 2179045fd02acca83127f8d15ccd0eeb70b17400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 3 Nov 2018 09:48:50 +0100 Subject: Clean up pthread_create() error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally pthread_create() rarely fails. But with new pthreads wrapper, pthread_create() will return ENOSYS on a system without thread support. Threaded code _is_ protected by HAVE_THREADS and pthread_create() should never run in the first place. But the situation could change in the future and bugs may sneak in. Make sure that all pthread_create() reports the error cause. While at there, mark these strings for translation if they aren't. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- preload-index.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'preload-index.c') diff --git a/preload-index.c b/preload-index.c index 0e24886aca..ddca1c216e 100644 --- a/preload-index.c +++ b/preload-index.c @@ -121,6 +121,8 @@ static void preload_index(struct index_state *index, for (i = 0; i < threads; i++) { struct thread_data *p = data+i; + int err; + p->index = index; if (pathspec) copy_pathspec(&p->pathspec, pathspec); @@ -129,8 +131,10 @@ static void preload_index(struct index_state *index, if (pd.progress) p->progress = &pd; offset += work; - if (pthread_create(&p->pthread, NULL, preload_thread, p)) - die("unable to create threaded lstat"); + err = pthread_create(&p->pthread, NULL, preload_thread, p); + + if (err) + die(_("unable to create threaded lstat: %s"), strerror(err)); } for (i = 0; i < threads; i++) { struct thread_data *p = data+i; -- cgit v1.2.3