From b038a61020573b1be6e5fc5b2be4485b63a9cbf1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 6 May 2012 19:31:56 +0700 Subject: [PATCH] index-pack: disable threading if NO_PREAD is defined MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit NO_PREAD simulates pread() as a sequence of seek, read, seek in compat/pread.c. The simulation is not thread-safe because another thread could move the file offset away in the middle of pread operation. Do not allow threading in that case. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index d4685c50d7..807ee56f79 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -39,6 +39,11 @@ struct base_data { int ofs_first, ofs_last; }; +#if !defined(NO_PTHREADS) && defined(NO_PREAD) +/* NO_PREAD uses compat/pread.c, which is not thread-safe. Disable threading. */ +#define NO_PTHREADS +#endif + struct thread_local { #ifndef NO_PTHREADS pthread_t thread; -- 2.11.4.GIT