git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] Makefile: add OPEN_RETURNS_EINTR knob

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 26, 2021, 22:17 UTC
Message-ID
<xmqq8s7ascby.fsf@gitster.g>
In-Reply-To
<YDiRywyld/0OTT5U@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 24 quoted lines
> However, note that we must not enable this on Windows. It doesn't do
> anything there, and the macro overrides the existing mingw_open()
> redirection. I've added a preemptive #undef here in the mingw header
> (which is processed first) to just quietly disable it (we could also
> make it an #error, but there is little point in being so aggressive).
> ...
> diff --git a/compat/open.c b/compat/open.c
> new file mode 100644
> index 0000000000..eb3754a23b
> --- /dev/null
> +++ b/compat/open.c
> @@ -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.
> +	 */
That is being extra careful---I like it very much.
Show 13 quoted lines
> +	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;
> +}
Thanks.
Show 17 quoted lines
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 838246289c..551cc9f22f 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -788,6 +788,12 @@ int git_vsnprintf(char *str, size_t maxsize,
>  		  const char *format, va_list ap);
>  #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
>  #if __GLIBC_PREREQ(2, 1)
>  #define HAVE_STRCHRNUL
Previous: Jeff KingNext: Jeff King
Message 6 of 15 in “wrapper: add workaround for open() returning EINTR”
  1. wrapper: add workaround for open() returning EINTRJeff King, Feb 24, 2021
  2. Jeff KingFeb 24, 2021
  3. Junio C HamanoFeb 24, 2021
  4. Jeff KingFeb 24, 2021
  5. Makefile: add OPEN_RETURNS_EINTR knobJeff King, Feb 26, 2021
  6. Junio C HamanoFeb 26, 2021
  7. config.mak.uname: enable OPEN_RETURNS_EINTR for macOS Big SurJeff King, Mar 1, 2021
  8. Junio C HamanoMar 1, 2021
  9. Junio C HamanoMar 1, 2021
  10. Jeff KingMar 3, 2021
  11. Junio C HamanoMar 4, 2021
  12. Taylor BlauFeb 24, 2021
  13. Johannes SixtFeb 24, 2021
  14. Jeff KingFeb 24, 2021
  15. Jeff KingFeb 26, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.