index-pack: disable threading if NO_PREAD is defined

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>

Nguyễn Thái Ngọc Duy committed May 6, 2012 at 19:31 UTC b038a61020573b1be6e5fc5b2be4485b63a9cbf1
1 file changed +5
builtin/index-pack.c
+5
@@ -39,6 +39,11 @@ struct base_data {
39 int ofs_first, ofs_last;
40 };
41
42 +#if !defined(NO_PTHREADS) && defined(NO_PREAD)
43 +/* NO_PREAD uses compat/pread.c, which is not thread-safe. Disable threading. */
44 +#define NO_PTHREADS
45 +#endif
46 +
47 struct thread_local {
48 #ifndef NO_PTHREADS
49 pthread_t thread;