Skip to content

Commit 2e1e8ef

Browse files
committed
Merge branch 'rj/platform-pread-may-be-thread-unsafe' into maint
On Cygwin, the platform pread(2) is not thread safe, just like our own compat/ emulation, and cannot be used in the index-pack program. Makefile variable NO_THREAD_SAFE_PREAD can be defined to avoid use of this function in a threaded program. * rj/platform-pread-may-be-thread-unsafe: index-pack: Disable threading on cygwin
2 parents 36c5109 + c0f8654 commit 2e1e8ef

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)