]> Pileus Git - ~andy/git/commitdiff
index-pack: disable threading if NO_PREAD is defined
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 6 May 2012 12:31:56 +0000 (19:31 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 May 2012 22:48:19 +0000 (15:48 -0700)
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

index d4685c50d7b4a4fec0c210725689d4d72029bda5..807ee56f79865cb04376268b051dceda5133f329 100644 (file)
@@ -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;