Merge branch 'jk/open-returns-eintr'
Work around platforms whose open() is reported to return EINTR (it shouldn't, as we do our signals with SA_RESTART). * jk/open-returns-eintr: config.mak.uname: enable OPEN_RETURNS_EINTR for macOS Big Sur Makefile: add OPEN_RETURNS_EINTR knob
This commit is contained in:
commit
921846fa22
7
Makefile
7
Makefile
@ -22,6 +22,9 @@ all::
|
|||||||
# when attempting to read from an fopen'ed directory (or even to fopen
|
# when attempting to read from an fopen'ed directory (or even to fopen
|
||||||
# it at all).
|
# it at all).
|
||||||
#
|
#
|
||||||
|
# Define OPEN_RETURNS_EINTR if your open() system call may return EINTR
|
||||||
|
# when a signal is received (as opposed to restarting).
|
||||||
|
#
|
||||||
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
|
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
|
||||||
#
|
#
|
||||||
# Define USE_LIBPCRE if you have and want to use libpcre. Various
|
# Define USE_LIBPCRE if you have and want to use libpcre. Various
|
||||||
@ -1539,6 +1542,10 @@ ifdef FREAD_READS_DIRECTORIES
|
|||||||
COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
|
COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
|
||||||
COMPAT_OBJS += compat/fopen.o
|
COMPAT_OBJS += compat/fopen.o
|
||||||
endif
|
endif
|
||||||
|
ifdef OPEN_RETURNS_EINTR
|
||||||
|
COMPAT_CFLAGS += -DOPEN_RETURNS_EINTR
|
||||||
|
COMPAT_OBJS += compat/open.o
|
||||||
|
endif
|
||||||
ifdef NO_SYMLINK_HEAD
|
ifdef NO_SYMLINK_HEAD
|
||||||
BASIC_CFLAGS += -DNO_SYMLINK_HEAD
|
BASIC_CFLAGS += -DNO_SYMLINK_HEAD
|
||||||
endif
|
endif
|
||||||
|
@ -227,6 +227,7 @@ int mingw_rmdir(const char *path);
|
|||||||
|
|
||||||
int mingw_open (const char *filename, int oflags, ...);
|
int mingw_open (const char *filename, int oflags, ...);
|
||||||
#define open mingw_open
|
#define open mingw_open
|
||||||
|
#undef OPEN_RETURNS_EINTR
|
||||||
|
|
||||||
int mingw_fgetc(FILE *stream);
|
int mingw_fgetc(FILE *stream);
|
||||||
#define fgetc mingw_fgetc
|
#define fgetc mingw_fgetc
|
||||||
|
25
compat/open.c
Normal file
25
compat/open.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "git-compat-util.h"
|
||||||
|
|
||||||
|
#undef open
|
||||||
|
int git_open_with_retry(const char *path, int flags, ...)
|
||||||
|
{
|
||||||
|
mode_t mode = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Also O_TMPFILE would take a mode, but it isn't defined everywhere.
|
||||||
|
* And anyway, we don't use it in our code base.
|
||||||
|
*/
|
||||||
|
if (flags & O_CREAT) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, flags);
|
||||||
|
mode = va_arg(ap, int);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
ret = open(path, flags, mode);
|
||||||
|
} while (ret < 0 && errno == EINTR);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
@ -124,6 +124,9 @@ ifeq ($(uname_S),Darwin)
|
|||||||
ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
|
ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 11 && echo 1),1)
|
||||||
HAVE_GETDELIM = YesPlease
|
HAVE_GETDELIM = YesPlease
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(shell test "`expr "$(uname_R)" : '\([0-9][0-9]*\)\.'`" -ge 20 && echo 1),1)
|
||||||
|
OPEN_RETURNS_EINTR = UnfortunatelyYes
|
||||||
|
endif
|
||||||
NO_MEMMEM = YesPlease
|
NO_MEMMEM = YesPlease
|
||||||
USE_ST_TIMESPEC = YesPlease
|
USE_ST_TIMESPEC = YesPlease
|
||||||
HAVE_DEV_TTY = YesPlease
|
HAVE_DEV_TTY = YesPlease
|
||||||
|
@ -788,6 +788,12 @@ int git_vsnprintf(char *str, size_t maxsize,
|
|||||||
const char *format, va_list ap);
|
const char *format, va_list ap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPEN_RETURNS_EINTR
|
||||||
|
#undef open
|
||||||
|
#define open git_open_with_retry
|
||||||
|
int git_open_with_retry(const char *path, int flag, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __GLIBC_PREREQ
|
#ifdef __GLIBC_PREREQ
|
||||||
#if __GLIBC_PREREQ(2, 1)
|
#if __GLIBC_PREREQ(2, 1)
|
||||||
#define HAVE_STRCHRNUL
|
#define HAVE_STRCHRNUL
|
||||||
|
Loading…
Reference in New Issue
Block a user