Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-11-18 12:23:52 +0300
committerJunio C Hamano <gitster@pobox.com>2018-11-18 12:23:52 +0300
commit26b80a841ad6f2ddff855aa9bd0000a4ba81f6ff (patch)
treeb2e5a385fe3e1825f11fa23de5c09cebe91c70a1 /preload-index.c
parent62ca33e02a4ea93dd59538ac986a082430253b27 (diff)
parent2179045fd02acca83127f8d15ccd0eeb70b17400 (diff)
Merge branch 'nd/pthreads'
The codebase has been cleaned up to reduce "#ifndef NO_PTHREADS". * nd/pthreads: Clean up pthread_create() error handling read-cache.c: initialize copy_len to shut up gcc 8 read-cache.c: reduce branching based on HAVE_THREADS read-cache.c: remove #ifdef NO_PTHREADS pack-objects: remove #ifdef NO_PTHREADS preload-index.c: remove #ifdef NO_PTHREADS grep: clean up num_threads handling grep: remove #ifdef NO_PTHREADS attr.c: remove #ifdef NO_PTHREADS name-hash.c: remove #ifdef NO_PTHREADS index-pack: remove #ifdef NO_PTHREADS send-pack.c: move async's #ifdef NO_PTHREADS back to run-command.c run-command.h: include thread-utils.h instead of pthread.h thread-utils: macros to unconditionally compile pthreads API
Diffstat (limited to 'preload-index.c')
-rw-r--r--preload-index.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/preload-index.c b/preload-index.c
index 222792ccbc..c7dc3f2b9f 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
-void preload_index(struct index_state *index,
- const struct pathspec *pathspec,
- unsigned int refresh_flags)
-{
- ; /* nothing */
-}
-#else
-
-#include <pthread.h>
+#include "thread-utils.h"
/*
* Mostly randomly chosen maximum thread counts: we
@@ -108,7 +98,7 @@ 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;
@@ -131,6 +121,8 @@ 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);
@@ -139,8 +131,10 @@ 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;
@@ -151,7 +145,6 @@ 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,