[PATCH 4/4] index-pack: disable threading if NO_PREAD is defined
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- May 6, 2012, 12:31 UTC
- Message-ID
- <1336307516-1809-4-git-send-email-pclouds@gmail.com>
- In-Reply-To
- <1336307516-1809-1-git-send-email-pclouds@gmail.com>
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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- builtin/index-pack.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index d4685c5..807ee56 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;
-- 1.7.8.36.g69ee2