git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Aleksey Kliger <alklig@microsoft.com>
Subject: Re: [PATCH v2] Makefile: add OPEN_RETURNS_EINTR knob
Date: Fri, 26 Feb 2021 14:17:53 -0800	[thread overview]
Message-ID: <xmqq8s7ascby.fsf@gitster.g> (raw)
In-Reply-To: <YDiRywyld/0OTT5U@coredump.intra.peff.net> (Jeff King's message of "Fri, 26 Feb 2021 01:14:35 -0500")

Jeff King <peff@peff.net> writes:

> 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.

> +	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.

> 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

  reply	other threads:[~2021-02-26 22:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  4:43 [PATCH] wrapper: add workaround for open() returning EINTR Jeff King
2021-02-24  4:46 ` Jeff King
2021-02-24  5:36   ` Junio C Hamano
2021-02-24 18:20     ` Jeff King
2021-02-26  6:14       ` [PATCH v2] Makefile: add OPEN_RETURNS_EINTR knob Jeff King
2021-02-26 22:17         ` Junio C Hamano [this message]
2021-03-01  9:29           ` [PATCH] config.mak.uname: enable OPEN_RETURNS_EINTR for macOS Big Sur Jeff King
2021-03-01 17:17             ` Junio C Hamano
2021-03-01 23:57             ` Junio C Hamano
2021-03-03 13:41               ` Jeff King
2021-03-04  0:47                 ` Junio C Hamano
2021-02-24  4:50 ` [PATCH] wrapper: add workaround for open() returning EINTR Taylor Blau
2021-02-24  7:20 ` Johannes Sixt
2021-02-24 18:23   ` Jeff King
2021-02-26  6:17     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8s7ascby.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=alklig@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).