Skip to content

Commit

Permalink
index-pack: disable threading if NO_PREAD is defined
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed May 7, 2012
1 parent b8a2486 commit b038a61
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b038a61

Please sign in to comment.