Skip to content

Commit c0f8654

Browse files
committed
index-pack: Disable threading on cygwin
The Cygwin implementation of pread() is not thread-safe since, just like the emulation provided by compat/pread.c, it uses a sequence of seek-read-seek calls. In order to avoid failues due to thread-safety issues, commit b038a61 disables threading when NO_PREAD is defined. (ie when using the emulation code in compat/pread.c). We introduce a new build variable, NO_THREAD_SAFE_PREAD, which allows use to disable the threaded index-pack code on cygwin, in addition to the above NO_PREAD case. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c8a9db commit c0f8654

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ all::
158158
# Define NO_PREAD if you have a problem with pread() system call (e.g.
159159
# cygwin1.dll before v1.5.22).
160160
#
161+
# Define NO_THREAD_SAFE_PREAD if your pread() implementation is not
162+
# thread-safe. (e.g. compat/pread.c or cygwin)
163+
#
161164
# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
162165
# generally faster on your platform than accessing the working directory.
163166
#
@@ -1051,6 +1054,7 @@ ifeq ($(uname_O),Cygwin)
10511054
NO_IPV6 = YesPlease
10521055
OLD_ICONV = UnfortunatelyYes
10531056
endif
1057+
NO_THREAD_SAFE_PREAD = YesPlease
10541058
NEEDS_LIBICONV = YesPlease
10551059
NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
10561060
NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
@@ -1659,6 +1663,10 @@ endif
16591663
ifdef NO_PREAD
16601664
COMPAT_CFLAGS += -DNO_PREAD
16611665
COMPAT_OBJS += compat/pread.o
1666+
NO_THREAD_SAFE_PREAD = YesPlease
1667+
endif
1668+
ifdef NO_THREAD_SAFE_PREAD
1669+
BASIC_CFLAGS += -DNO_THREAD_SAFE_PREAD
16621670
endif
16631671
ifdef NO_FAST_WORKING_DIRECTORY
16641672
BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ 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. */
42+
#if !defined(NO_PTHREADS) && defined(NO_THREAD_SAFE_PREAD)
43+
/* pread() emulation is not thread-safe. Disable threading. */
4444
#define NO_PTHREADS
4545
#endif
4646

0 commit comments

Comments
 (0)