Skip to content

Commit b038a61

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent b8a2486 commit b038a61

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin/index-pack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ struct base_data {
3939
int ofs_first, ofs_last;
4040
};
4141

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+
4247
struct thread_local {
4348
#ifndef NO_PTHREADS
4449
pthread_t thread;

0 commit comments

Comments
 (0)